$ git log
You should see a less
'd list of your log in descending chronological order (top of the list is your most recent commit).
- Find the commit you want to revert back to.
- Copy the hash (hexadecimal string, like: "b4533eeac95f970d131452b08db9094e8e07a260")
- Press "q" to quit
Do this to keep your changes in the history, but switch back to a previous commit; Good in case you have merged into another branch or someone else has a copy of your branch.
me@local:mygitrepo$ git diff HEAD..$HASH_YOU_COPIED > diff.patch
me@local:mygitrepo$ git apply diff.patch
me@local:mygitrepo$ rm diff.patch
me@local:mygitrepo$ git commit -a -m "Reverted back to HASH_YOU_COPIED"
Check to make sure that everything is back to the way that it was before.
Then:
me@local:mygitrepo$ git push
WARNING
Only do this when your code hasn't been merged into develop yet!
me@local:mygitrepo$ git reset --hard $HASH_YOU_COPIED
Check to make sure that everything is back the way that it was before.
Then:
me@local:mygitrepo$ git push --force
This will force the remote to the hash that you reset your tree to