Revert a Commit

Revert a Commit

Don’t Panic! Well, panic a little
Once you notice the pipeline is red, do these in this exact order
 
  1. git revert <your commit hash All a git revert does is create a new commit that excludes the changes in the breaking commit you’re reverting
  1. git pull -r If anyone has pushed after you, possibly with your broken code, this will merge theirs into your code and put your revert commit at the top. If no one else pushed, don’t stress
  1. git log to check the order is right: <Reverted Commit> <Someones Good Commit> <Your Broken Commit>
  1. git push Remote will now run with your broken code removed but the other peoples code added
 
Now you need to debug your error and push once you’ve fixed it
  1. git checkout <commit before revert hash> To get the the point where thing’s broke
  1. Make your fixes
  1. git push a new revision, alternatively you fucked up so maybe push to a branch and validate the pipeline is okay git checkout -b <branch name
 

Guides and practical notes, training references, and code snippets shared freely for learning and career growth.