6

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?

Community
  • 1
  • 1
Noble-Surfer
  • 3,052
  • 11
  • 73
  • 118
  • Does this answer your question? [Why does git say "Pull is not possible because you have unmerged files"?](https://stackoverflow.com/questions/26376832/why-does-git-say-pull-is-not-possible-because-you-have-unmerged-files) – Flimm Jan 03 '22 at 12:37

2 Answers2

11

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
Sajib Khan
  • 22,878
  • 9
  • 63
  • 73
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/130214/discussion-between-sajib-khan-and-someone2088). – Sajib Khan Dec 09 '16 at 12:24
  • How would I do that? I haven't changed the configuration of the server at all since it was last working... all I have done is the `soft reset`, but I've not actually changed any of the server settings... – Noble-Surfer Dec 09 '16 at 12:24
0

first give git stash command-->You will get the files which has conflicts Then Use Git add filename and hit enter Then enter git pull