when i try to pull in my local directory, i got error like this.
$ git pull
error: Pulling is not possible because you have unmerged files.
hint: Fix them up in the work tree, and then use 'git add/rm <file>'
hint: as appropriate to mark resolution and make a commit.
fatal: Exiting because of an unresolved conflict.
So, i solved this problem by use this command
git reset --hard HEAD
β do you have other suggestions? Please write in below
Top comments (7)
I mean, hard resetting certainly is a solution, but you really shouldn't do that just to solve this error.
Unmerged changes are changes (to files potentially getting pulled) that you might want to keep. Hard resetting erases all of that work.
A better solution is generally
git stash
, but at the very least you should verify your current repo state withgit status
andgit diff
to figure out what is actually in your unmerged changes, and potentially commit them before pulling. (git pull --rebase
followed by agit reset HEAD~1
can then also be similarly useful as stashing, with the added benefit of resolving conflicts along the way).ouwh very useful, i will try this in the future :)
Best thing to do is:
git stash <β ditch your changes
git pull <β Pull in the latest changes
git stash pop <β any changes prior to git stash will be added back in.
Lemme know how you get on
hint (3): use git status
thanks for your addition
git pull --autostash
is what I usually do in those situations. It'll automatically try to rebase your changes on the pulled version.thanks for your addition, i'll try in the next time π