Skip to main content

Posts

Showing posts from May, 2026

Git Revert is Easier Than You Might Think

    Its surprisingly easy and not as complicated as some people might say. You just need to know which one is the 'bad' commit, then revert to one commit before the 'bad' one. In this example, person 'M' accidentally pulled from the dev branch instead of main. So to revert this, just follow these steps: Find the 'bad' commit In this case it's git message have something like 'pulled dev into branch...'. This is the bad commit, do not copy the git hash of this commit. Instead, get the last 'good' commit. Copy the commit hash of the one before the 'bad' one. Paste it somewhere safe, we will get back to this later. Do not revert right now.   Backup your commits after the 'bad' one After pulling from dev, 'M' pushed a few more commits afterwards. If we've already reverted, finding the committed changes would be a bit harder. So now is the best chance to copy all the commit hashes for cherry-picking later.    Rev...