Function of revert:

  • revert a commit to let those changes not happen
  • this is a way useful for a part of a team to just cancel his/her commits without affecting other pulls

Representative Methods:

  1. git revert <commit-serial-number>

this revert the commit with the corresponding serial number.
OR

  1. git revert HEAD~1

this revert a commit before HEAD.

commit-serial-number:

  • we can get the commit serial number with:
    1. git log
    image.png
    the long string after “commit” is the commit serial number we need.

Rules of revert:

  • cannot revert HEAD
  • if a file was changed for several times, you can only start reverting from the latest one