I just ran
git pull --rebase
and forget to specify "origin". It looks like git pulled from all different branches. Is there a way to revert my repo from here to undo the pull?
Thanks
After a git pull
operation, ORIG_HEAD
should point to the previous value of HEAD
. You should be able to:
git reset --hard ORIG_HEAD
And be back where you started before the pull
operation. You can run:
git show ORIG_HEAD
To see exactly where ORIG_HEAD
is pointing prior to running the reset
command.
An alternative solution would be to create a new branch based on ORIG_HEAD
:
git checkout -b newbranch ORIG_HEAD
Verify that things look the way you expect, then delete the old branch and rename new branch
.
Also see this question for a discussion of HEAD
and ORIG_HEAD
and alternate syntaxes for referring to the same thing.
Use git reflog
You will see a whole bunch of commits HEAD that are from the past.
Safest is to checkout the HEAD you need in a new branch and continue from there
git checkout -b phew HEAD@{x} # fill in the number of the commit you need.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With