I have working directory (#1) which has vendor directory(#2) in it. There is one dependency which I wanted to pull manually without composer (php version of npm/gem). I was working in #1, haven't saved/commited changes, when I decided I want to update library in #2. I navigated to vendor/myname, and did git pull repository.
Unfortunately it started to pull and merge to #1, instead of creating new directory in vendor folder.
Now I have:
I want to "undo" this last git pull without loosing any changes I did to folder #1. How can I do this?
git merge --abort
might be what you're looking for.
Modern Git:
git merge --abort
Older:
git reset --merge
Old-school (warning: will discard all your local changes):
git reset --hard
But actually, it is worth noticing that git merge --abort
is only equivalent to git reset --merge
given that MERGE_HEAD
is present. This can be read in the git help for merge command.
git merge --abort is equivalent to git reset --merge when MERGE_HEAD is present.
After a failed merge, when there is no MERGE_HEAD
, the failed merge can be undone with git reset --merge
but not necessarily with git merge --abort
, so they are not only old and new syntax for the same thing. Personally I find git reset --merge
much more useful in everyday work.
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