Andrew Maddison


Git Revert Workflow

I recently had trouble remembering how to revert in Git, or more accurately, how to recover the work afterwards in order to fix it. Here are the commands for a straightforward revert.

git log

Make sure you know the hash/number of the commit you want to revert

git revert [Hash of commit to revert]

This will revert the commit, and apply it (locally) as another commit. You can now push or whatever. Then to retrieve your changes back into your working copy (to fix etc)

git revert -n [hash of the reverting commit]

This should get you back to having your changes locally - so you can fix ready to push again.