If you find git confusing, I created this little cheat sheet! Please, note that I voluntarily
skipped the basic commands like git commit
, git pull/push
… This cheat sheet is intended for
advanced usage of git.
🧭 Navigation - Go to the previous branch
🔍 Get the history
🙈Ooops #1: I reseted an unwanted commit. How to rollback?
For more detail about this command, I wrote another post: What’s happens when you ‘git commit’.
🤦♀️Ooops #2: I mixed-up with my local repo. How to clean it?
🕵🏻♂️Difference between my branch and master
✔ Custom commits
If you don’t know what to put in your commit messages, I wrote a post about conventional commits.
♻️ Squash commits
Let say I want to rebase the last 3 commits:
git rebase -i HEAD~3
- Leave the first “pick” and replace the rest by “
squash
” (or “s
”) - Tidy up the commit message and save (
:wq
in vi).
🎯Fixup
Let say I want to add something in the commit fed14a4c
🕹Execute command on each commit when rebasing
For massives features, you might end up with a branch with a few commits inside. And then tests are
failing and you want to identify the “guilty commit”. You can use rebase --exec
to execute a
command on each commit of the history.
🦋Stash
Because it’s not all about git stash
and git stash pop
;)
🗑 Clean
🐙 GitHub = Git
+ Hub
I use Hub as a wrapper for git. To enable it you’ve to set hub as
an alias for git (alias git='hub'
).
Other commands are available here.
🦄 Bonus: my favourite git aliases
And you, what’s your favourite git command?
About the author
Hey, I'm Maxence Poutord, a passionate software engineer. In my day-to-day job, I'm working as a senior front-end engineer at Orderfox. When I'm not working, you can find me travelling the world or cooking.
Follow me on BlueskyRecommended posts
Thomas Harris is a fraudulent YouTuber who uses fake crypto tutorials to spread malware. He artificially inflates his channel's popularity and promotes a malicious script that downloads harmful files and steals crypto. This scam, powered by AI-generated content, highlights the growing sophistication of online threats.
How Testing Library helps you to write better integration test