-
wipe out all uncommitted changes that made:
git checkout . -
But it will not wipe out new files that were not committed yet. to remove all uncommitted changes including newly created files:
git stash git stash drop
-
if change is already committed but commit is not pushed yet, reset can be used.
git reset HEAD -
in case of multiple commits: for example if you want to remove last 3 commits
git reset HEAD~3
-
if change is pushed to remote, revert is good choice.
git revert <commit>it will make a new commit undoing changes in .
-
to revert last 5 commits:
git revert HEAD~5
-
You merged/pulled a branch, now want to undo that. If you did not pushed your changes to remote, you are a somewhat lucky. you can just reset to your previous commit.
git reset HEAD~1 -
If you have merged and pushed to remote server already, but now you want to undo that. you can revert the merge commit. All you have to do is specify the merge commit you want to revert and the parent line you want to keep.
git revert -m 1 <commit>
For Details:
http://stackoverflow.com/documentation/git/285/undoing#t=201608081847457707859