Page History

Turn Off History

Single Commit Revert

  1. Get the SHA1 ID.
  2. git checkout BRANCH
  3. git revert SHA1ID

Multiple commits in a single revert

If you want to roll back a bunch of commits, you could do multiple reverts. But if you want the reverts to be a single commit:

  1. Get the SHA1 IDs.
  2. git checkout BRANCH
  3. git revert --no-commit SHA1ID
    • Repeat for each SHA1 ID
  4. git commit

Don't propogate a revert upstream

You might want to revert a buggy change on one branch while keeping it on upstream branches. For example, you have a buggy fix on V7_8_1-branch, and need to revert it because it missed the 7.8.1 release deadline. However, you've been merging your work forward to V7_8-branch and master, and you'd like to keep your work there. If you skip merging, someone in the future might do the merge not realizing an undesirably commit is in there and clobber your work.

  1. Get the SHA1 ID.
  2. git checkout V7_8_1-branch
  3. git revert SHA1ID
  4. git checkout V7_8-branch
  5. Merge the revert in, but don't commit yet:
    git merge --no-commit V7_8_1-branch
  6. Identify files you don't want to commit:
    git status
  7. For each merged file:
    git reset FILENAME
  8. For each merged file:
    git checkout FILENAME
  9. Add and commit your changes as usual
    git add FILENAME
    git commit