Dennis Hackethal’s Blog
My blog about philosophy, coding, and anything else that interests me.
Handy Git Commands
These are the top five handiest git commands I use. I’m keeping this list as simple as possible – check the linked references to learn more.
$ git log -p
Want to see a history of changes instead of just a history of commit messages? This command will show the changes between all commits in your current branch.
$ git add --patch
Want to stage some hunks but not others? This command will walk you through them all, step by step, giving you granular control over which hunks to stage.
$ git diff --word-diff
For long lines, small changes can be difficult to see in the default line-based diffs. Use a word-based diff instead to see exactly what’s changed.
$ git cherry-pick <commit-id>
Need a commit from another branch but don’t want to merge? Simply
cherry-pick the commit.
$ git stash
Not ready to commit your changes, but need to clear them temporarily? Stashing will undo your changes (staged or not) while also saving them separately so you can reapply them later by running
$ git stash apply.
What people are saying