githubteacher / github-for-developers-sept-2015

practice repo for the Sept 29-30 GitHub for Developers class
12 stars 36 forks source link

How to revert a commit? #641

Closed snigdhajain closed 9 years ago

sreedasari commented 9 years ago

:+1:

sanjay990 commented 9 years ago

if you want to completely remove the last commit locally .. you can use git reset --hard HEAD~1

jaw6 commented 9 years ago

To revert a commit, first locate that commit's SHA (eg, abc123). Then:

git revert <SHA>

Keep in mind: Git will require more information if you're attempting to revert a merge commit, as merge commits have two (or more) parents. If you want to revert a merge, it's usually best to use the Revert button in the GitHub pull request, as it will revert all the commits in the pull request in one, and you don't need to specify which parent to revert to. (GitHub pull requests know which branches were involved in the original pull request, but Git doesn't actually preserve that information.)