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

Daniel Pepuho @danielcristho

About: Exploring Distributed Systems, Cloud Technologies ☁️, Open Source Projects 🟢, and Python Automation 🐍

Location:
Jayapura, Papua
Joined:
Aug 27, 2021

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

Publish Date: Feb 13 '22
31 7

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

Comments 7 total

  • Offline
    Offline Feb 13, 2022

    hint (3): use git status

  • FJones
    FJonesFeb 13, 2022

    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).

    • Daniel Pepuho
      Daniel PepuhoFeb 13, 2022

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

  • Zak Hargreaves
    Zak HargreavesFeb 13, 2022

    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

  • Alex Lohr
    Alex LohrFeb 13, 2022

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

    • Daniel Pepuho
      Daniel PepuhoFeb 14, 2022

      thanks for your addition, i'll try in the next time 😄

Add comment