Skip to main content

How to Undo Git Pull

If you have done a git pull and want to revert it follow the following steps

Step1: See recent commits

Use git reflog to see recent commits. You will see something like this:
38a8d67 HEAD@{0}: pull: Fast-forward
207b7e7 HEAD@{1}: commit: frontend errors and saving files
04bbc08 HEAD@{2}: commit: s3 delete working
da01b7a HEAD@{3}: commit: linked to S3
2f3e8ff HEAD@{4}: commit: removed morgan completely
e0db8da HEAD@{5}: commit: removed morgan
6389f3a HEAD@{6}: commit: updated with security middlewares
8034f81 HEAD@{7}: commit: added dotenv to dependencies
3f92a3e HEAD@{8}: commit: added morgan to dependencies

Step 2: Copy the hash of the commit you want to revert to

Example, I made the pull request "Fast-forward" and want to revert to the commit with the comment "frontend errors and saving files".

Step 3: Press "q" to get out of this view

Step 4: Use git reset --hard <hash>

In my case I will use git reset --hard 207b7e7

Comments