Dennis Hackethal’s Blog

My blog about philosophy, coding, and anything else that interests me.

Published · 1-minute read

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.

Reference


$ 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.

Reference


$ 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.

Reference


$ git cherry-pick <commit-id>

Need a commit from another branch but don’t want to merge? Simply cherry-pick the commit.

Reference


$ 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.

Reference


What people are saying

What are your thoughts?

You are responding to comment #. Clear

Preview

Markdown supported. cmd + enter to comment. Your comment will appear upon approval. You are responsible for what you write. Terms, privacy policy
This small puzzle helps protect the blog against automated spam.

Preview