Wednesday, June 9, 2010

git: delete last commit

git reset --hard HEAD~1
 
HEAD~1 is the commit before the HEAD branch. You could also use the SHA-1 hash of the
commit you want to revert to.
 
Using --hard would remove all untracked files in your working directory so BACKUP! 
 
git revert HEAD
 
If however you have pushed the wrong commit already. Use this. This one makes another 
commit from HEAD (or whatever commit you want to revert to). Then push it again.

No comments:

Post a Comment