Git revert undoes a single commit. It does not revert back to a previous state of the project by removing previous commits. In git this is called reset.

If you have published work to your origin, you probably don’t want to reset the branch since that is effectively rewriting history. In this case you will want to revert the commits. This will create new commits that will reverse the unwanted commits. This way the history is not rewritten.

git revert <commit>

#Revert vrs Reset

  
Reverting
----------↘
(A) - (B) - (C) - (B-)

B- is a new commit that reverses the changes in B commit
  
Resetting
↙---
(A) - (B) - (C) - (D)

D is now removed

#Reverts the last two commits git revert HEAD~2..HEAD

#Reverting a merge commit git revert -m 1



blog comments powered by Disqus

Published

20 August 2014

Tags