Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in DevOps and Agile by (29.3k points)
edited by

I would like to undo my git pull on account of unwanted commits on the remote origin, but I don't know which revision I have to reset back to.

How can I just go back to the state before I did the git pull on the remote origin?

1 Answer

0 votes
by (50.2k points)

To undo a git-pull you could use: 

git reset --keep HEAD@{1}

This command will undo the pull command and return back to the previous state.

In the older version of git the command is something like:

git reset --hard HEAD@{1}

This command can erase all the local changes. You need to be more careful using -- hard option.

Refer: https://git-scm.com/docs/git-reset#Documentation/git-reset.txt---keep

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...