Git Notes
· One min read
Branches (git branch / git checkout)
Switching Branches
git checkout <branch_name>
Deleting Branches
git branch -d <branch_name>
Creating an Empty Branch
git checkout --orphan=<branch_name>
git reset --hard
Log
Displaying the Log
git log --decorate=full --graph --all
note
If you have access to VS Code, it's a good idea to install the Git Graph extension.
Going Back in Time
# Find the commit ID
git log
git checkout <commit_id>
note
Commit IDs are 4 characters and can be abbreviated.
Going Back from the Past
git checkout <branch_name>
Undoing Commits (git reset)
git reset --soft @^
note
@ is the same as HEAD. ^ represents the previous commit.
