Quick Fix: Undoing a Git Pull from the Wrong Branch

I've received many questions about how to undo a pull from the wrong branch in Git. This can be confusing for some, so I'll keep it simple and focus on a quick solution:

1- Identify the commit you want to revert to, which contains your changes and the rest of the code.

2- In your Git Bash, type the command: git reflog it shows the history of all your actions in Git, including pulls

3- Once you find the correct commit, take note of the corresponding HEAD@{x}, where x is a number.

4- Finally, type git reset --hard HEAD@{x} in Git Bash to revert to that commit.

I hope this helps clear things up!

To view or add a comment, sign in

Insights from the community

Others also viewed

Explore topics