Git Cheat Sheet
01 Aug 2022 - Alejandro Piña
Basic git commands that are used day to day
Branches Graph
View graph with basic information including commit short ID
git log --all --decorate --online --graph
You can wrap graph command in a short command with an alias e.g.
echo "alias gitgraph='git log --all --decorate --oneline --graph'" >> ~/.bash_aliases
Working with commits
Revert changes
--soft
reverts changes to stagging area--mixed
reverts changes to working directory preserving modifications--hard
reverts changes including modifications
git reset --soft <commit_short_id>
Reorganizes current branch commits after HEAD <branch_name>
, make sure that you fetched your braches before this operation
git reset <branch_name>
Logs
Shows information about the commit like modifications and author
git show <commit_short_id>
Shows who mades the modifications line by line
-L
shows part of the content<from,to>
git blame <filename> -L 0,10