我刚尝试用另一个分支替换我服务器上的master
分支,因为master
已被破坏,我似乎无法解决错误......
我替换它的分支是我的最后一个工作版本。我通过从本地计算机运行以下命令来完成此操作:
git checkout lastWorkingBranch
git merge -s our master
git checkout master
git merge lastWorkingBranch master
git push origin master
然后,在服务器上,我跑了
git pull origin master
然而,这给出了以下输出:
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
我试过提交&amp;再次在本地计算机上推送,然后在服务器上再次运行pull
,现在收到以下消息:
U costing / views.py U tools.py 由于您有未合并的文件,因此无法进行拉取。 请在工作树中修复它们,然后使用&#39; git add / rm&#39; 适用于标记解决方案,或使用“git commit -a”#。 root @ moon:/ code / moon#
我不明白为什么我会这样......?我合并并推送了所有文件 - 如何在工作树中修复它们?
答案 0 :(得分:9)
你有一些未合并的文件。因此,首先要执行commit
或stash
个文件。
$ 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