Imagine this: you’ve been paged to investigate a production incident, and after some digging, you identify the commit with the breaking code. You decide to revert the change:
git revert 1a2b3c
Unfortunately, in doing so, a new bug is introduced! As it turns out, hidden in that old “broken” commit was some code that another part of the app depended upon, and when you reverted those lines, it left the site once again in a broken state. 🙃 Oh dear.
How can situations like this be avoided? To answer this question, we first need to examine how these types of commits come to be.
If you’ve never heard of or used
git reset… this article is a must-read.