Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git pull not possible because of unmerged files

I have just tried replacing the master branch on my server with another branch, as the master was broken, and I couldn't seem to resolve the error...

The branch that I replaced it with is the last working version I had. I did this by running the following commands from my local machine:

git checkout lastWorkingBranch

git merge -s ours master

git checkout master

git merge lastWorkingBranch master

git push origin master

Then, on the server, I ran

git pull origin master

However, this gave the following output:

Pull is not possible because you have unmerged files.
Please, fix them up in the work tree, and then use 'git add/rm <file>'
as appropriate to mark resolution, or use 'git commit -a'.
root@moon:/code/moon# git stash
costing/views.py: needs merge
tools.py: needs merge
costing/views.py: needs merge
tools.py: needs merge
costing/views.py: unmerged (395725168ffab1962655116880b74158de3e1e56)
costing/views.py: unmerged (95ff89d4160135c2ebefd67a0fc1af2f2a0abc74)
costing/views.py: unmerged (902f9ff57c808cefd074f3ea07fb252f9eedb4e2)
tools.py: unmerged (6832dd3197f838a52396381c30ef55069e24411b)
tools.py: unmerged (24e8179f7689ffacdd50407259f3a12b3d3f609a)
tools.py: unmerged (93b3d0baa5f1b75c85120cc2e7cab7dcd949b9a5)
fatal: git-write-tree: error building trees
Cannot save the current index state

I tried committing & pushing again on my local machine, and then ran a pull again on the server, and now get the following message:

U costing/views.py U tools.py Pull is not possible because you have unmerged files. Please, fix them up in the work tree, and then use 'git add/rm ' as appropriate to mark resolution, or use 'git commit -a'. root@moon:/code/moon#

I don't understand why I'm getting this...? I have merged and pushed all of my files- how do I fix them up in the work tree?

like image 632
Noble-Surfer Avatar asked Dec 09 '16 11:12

Noble-Surfer


People also ask

Why does Git say “Pull is not possible because you have unmerged”?

Why does git say “Pull is not possible because you have unmerged files”? What is currently happening is, that you have a certain set of files, which you have tried merging earlier, but they threw up merge conflicts.

How to pull unmerged files in Git?

repo_clone $ git pull U file Pull is not possible because you have unmerged files. Please, fix them up in the work tree, and then use 'git add/rm <file>' as appropriate to mark resolution, or use 'git commit -a'. Note that the file now is in an unmerged state and if we do a git status, we can clearly see the same:

Why is Git throwing up a U (unmerged) flag?

It so happens, that your merge conflicts from (probably) the last commit were not not resolved, so your files are not merged all right, and hence the U ( unmerged) flag for the files. So now, when you do a git pull, git is throwing up the error, because you have some version of the file, which is not correctly resolved.

Why do I get a U (unmerged) error when I pull?

It so happens, that your merge conflicts from (probably) the last commit were not not resolved, so your files are not merged all right, and hence the U (unmerged) flag for the files. So now, when you do a git pull, git is throwing up the error, because you have some version of the file, which is not correctly resolved.


1 Answers

You have some unmerged files. So, first do commit or stash the files.

$ git commit -am <message>          # add and commit
$ git pull origin master            # pull origin

Or,
$ git add .                         
$ git stash                         # remove the files
$ git pull origin master
like image 130
Sajib Khan Avatar answered Oct 12 '22 18:10

Sajib Khan