To undo a git commit, you have a couple of options: git revert and git reset. You can also amend prior commits.
Git
Git tips and tricks
Git is an essential development tool, and an endless stream of things to learn. This post is some of the tips, tricks, and configurations I use to make life easier day-to-day. Here’s what’s below: Disclaimer: I’m not a git expert. These are just things that have come in handy in my years as a heavy […]
Git Stash
Git stash is for stashing away changes you need but aren’t quite ready to commit. The command saves your local modifications away and reverts the working directory to match the HEAD commit. – Git Docs There are a few important stash-related commands. Git stash Say you’re on the main branch, and you started making edits […]
Git Diff
When you want to compare two branches, use git diff. I usually like to pair it with the –stat option for a quick visual summary. Git diff branch_name.. Let’s say I’m on a test branch, and I want to see how that branch differs from main. I can get a quick overview via git diff […]
Git log customization
The git log command outputs a lot of useful information—message, author, date, hash, branch—but its default format leaves something to be desired. Mostly, it just takes up too much screen space. Here’s an example, using the popular Python package flask: The default git log above has all the information we want, but just two commits […]
Git commit and commit message best practices
I’ve seen lots of advice about git commits and messages over the years—some good, some not so good. This post will go through what works for me. Note: I’m no git workflow expert, these are just my personal opinions developed over ~10 years working at startups. Commit Best Practices: Commit Message Best Practices: Let’s go […]
Git commit amend
Maybe there’s a typo in your most recent commit message, or maybe you forgot to add a file. Git commit –amend allows you to go back and modify your commit—no one has to know you made a mistake. Amend a previous commit message Here’s a quick example fixing a typo in a message: Amend the […]