Undo pull and recover to previous HEAD commit
If you want to undo git pull
action which has been executed and go back to the previous state, use :
# Undo pull action
# --hard, not only reset the current branch and staging area, but also working directory
# ORIG_HEAD, the old HEAD, here it is the HEAD before pull action
$ git reset --hard ORIG_HEAD
Undo pull but keep unstaged changes in working directory
Note the command above will discard changes you have made in working directory. If you have not staged them and want to keep, use --merge
option instead :
# Undo pull action but keep unstaged changes in working directory
$ git reset --merge ORIG_HEAD