xxxxxxxxxx
# This will create three separate revert commits:
git revert a867b4af 25eee4ca 0766c053
# It also takes ranges. This will revert the last two commits:
git revert HEAD~2..HEAD
#Similarly, you can revert a range of commits using commit hashes (non inclusive of first hash):
git revert 0d1d7fc..a867b4a
# Reverting a merge commit
git revert -m 1 <merge_commit_sha>
# To get just one, you could use `rebase -i` to squash them afterwards
# Or, you could do it manually (be sure to do this at top level of the repo)
# get your index and work tree into the desired state, without changing HEAD:
git checkout 0d1d7fc32 .
# Then commit. Be sure and write a good message describing what you just did
git commit
I have a simple solution using a patch to revert all your changes.
1. Checkout current head branch (e.g. develop)
git checkout develop
2. Lookup your commit-id in the history log, and check out only your changes into a new branch:
git log
git checkout -b your-branch
3. Look up in your branch, and find the previous status you want to revert to:
git checkout -b prev-status
4. Create a patch that can revert all your changes:
git diff your-branch..prev-status > reverts.patch
# the comparing order of branches is important
5. checkout current head branch and apply the reverting patch
git checkout origin develop
git apply reverts.patch
git add *
git commit -m "revert all my changes"