Home / blog / useful-git-commands

Enero 4, 2024

1 minuto de lectura

Useful git commands


Disclaimer: sería bueno que verifiques cómo funcionan los comandos antes de ejecutarlos, chatgpt es una buena opción btw.

Add changes

git add *
git commit -m "description"
git push

Undo last commit keeping changes

git reset --soft HEAD~1

Undo last commit without keeping changes

git reset --hard HEAD~1

Show changes

git status

Show commit history

git log

Show current branch

git branch

Show remote repository

git remote -v

Create branch

git checkout -b "some_branch"

Clone remote branch

git checkout --track origin/some_branch

Get last version of master

git pull origin master

Show all branches

git branch -a

Delete local branch

git branch -d "some_branch"

Force delete local branch

git branch -D "some_branch"

Delete remote branch

git push origin --delete "branch"

Move to master

git checkout master
git pull

Push to master branch in an existing repository

git remote add origin https://url.git
git push -u origin master

Pull from another branch

git pull origin "some-branch"

Merge with another branch

git merge "some-branch"