DEV Community

Daniel Pepuho
Daniel Pepuho

Posted on

error: Pulling is not possible because you have unmerged files. How to solve?

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.
Enter fullscreen mode Exit fullscreen mode

So, i solved this problem by use this command

git reset --hard HEAD
Enter fullscreen mode Exit fullscreen mode

⭐ do you have other suggestions? Please write in below

Top comments (7)

Collapse
 
fjones profile image
FJones

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 with git status and git diff to figure out what is actually in your unmerged changes, and potentially commit them before pulling. (git pull --rebase followed by a git reset HEAD~1 can then also be similarly useful as stashing, with the added benefit of resolving conflicts along the way).

Collapse
 
danielcristho profile image
Daniel Pepuho

ouwh very useful, i will try this in the future :)

Collapse
 
zakhargz profile image
Zak Hargreaves

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

Collapse
 
offline profile image
Offline

hint (3): use git status

Collapse
 
danielcristho profile image
Daniel Pepuho

thanks for your addition

Collapse
 
lexlohr profile image
Alex Lohr

git pull --autostash is what I usually do in those situations. It'll automatically try to rebase your changes on the pulled version.

Collapse
 
danielcristho profile image
Daniel Pepuho

thanks for your addition, i'll try in the next time πŸ˜„