'How to revert a wrong Git pull (remote to local) [duplicate]

I pull a wrong remote branch to local i.e Merge branch 'remote' of ://github.../remote into Local

A right click in TortoiseGit -> Revert changes by this commit is requesting to revert to either "parent 1" or "parent 2". I simply want to cancel the pull remote into local, what should chose ?



Solution 1:[1]

  1. Find the original commit your branch was on before you pulled.

ORIG_HEAD points to the original head of a branch before it was changed in a drastic way. "Drastic" means something more than a simple commit, like git reset or git pull. Verify ORIG_HEAD points at your pre-pull commit with git log ORIG_HEAD.

If it isn't, you can use git log --graph --decorate to find the commit before the pull. Or you can use git reflog to look at where HEAD was every time it changed.

  1. Reset the branch.

Assuming it's ORIG_HEAD: git reset --hard ORIG_HEAD

This will move the branch back to the specified commit as if the pull never happened.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Schwern