git : Pull 是不可能的,因为你有未合并的文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/46404139/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
git : Pull is not possible because you have unmerged files
提问by Nilesh
I am using php-git client to pull branches in my php script. and whenever i do checkout from master to testing i get following error.
我正在使用 php-git 客户端在我的 php 脚本中提取分支。每当我从 master 结帐到 test 时,我都会收到以下错误。
error: Pull 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.
my files are on bitbucket server. and i add/modify files on bitbucket and commit there.
我的文件在 bitbucket 服务器上。我在 bitbucket 上添加/修改文件并在那里提交。
I dont understand , I dont mofify anything on my local machine, still i get this error.
我不明白,我没有在本地机器上修改任何内容,但仍然出现此错误。
Following is my 'git status' output.
以下是我的“git status”输出。
Your branch is up-to-date with 'origin/testing'.
You have unmerged paths.
(fix conflicts and run "git commit")
(use "git merge --abort" to abort the merge)
Changes to be committed:
modified: g_1.0.yaml
new file: potter_3.4.yaml
new file: potter_3.4.yml
Unmerged paths:
(use "git add <file>..." to mark resolution)
both modified: abc_1.0.json
回答by MrKekson
You are in the middle of a merge, try to read the messages you copied, it's pretty clear what you should do: You have unmerged paths. (fix conflicts and run "git commit") (use "git merge --abort" to abort the merge)
您正处于合并过程中,尝试阅读您复制的消息,很清楚您应该做什么:您有未合并的路径。(修复冲突并运行“git commit”)(使用“git merge --abort”中止合并)
So first clear up the merge conflicts
所以首先清除合并冲突
use the merge tool of your choice (eg: tortoise merge, meld )
or do it by hand, in the conflicted file you should see arrows like
<<<<<<< HEAD, select the appropriate one(s)
使用您选择的合并工具(例如:tortoise merge、meld)
或手动完成,在冲突的文件中,您应该看到像 <<<<<<< HEAD 之类的箭头,选择适当的一个
and then commit
然后提交
git commit -m "foobar"
Now you should be able to push/pull from your remote, but you may need to pull first, to get the new changes merged locally.
现在您应该能够从远程推/拉,但您可能需要先拉,以便在本地合并新更改。
Alternatively, if you don't need your code, and just want to toss out everything and get master, you can allays
或者,如果你不需要你的代码,只想扔掉所有东西并获得主人,你可以减轻
git reset --hard origin/master
to reset your local repo to the state of origin/master, but you will loose all local changes
将您的本地存储库重置为原始/主状态,但您将丢失所有本地更改
回答by LeGEC
There is a file in the Unmerged paths:
section : abc_1.0.json
.
部分中有一个文件Unmerged paths:
:abc_1.0.json
。
This is the sign of a conflict. It probably appeared when you ran a previous git pull
from this same branch.
这是冲突的征兆。当您git pull
从同一分支运行前一个时,它可能会出现。
You now have to choose :
您现在必须选择:
if you know that you have something which you modified in
abc_1.0.json
, and that you need to keep this modification in this file, resolve the conflict :- open
abc_1.0.json
in your editor - look for the conflict markers (lines looking like :
<<<<< HEAD
,=====
,>>>>> testing
) - choose what version should be kept
- open
if you know that the current merge is not important, you can run
git merge --abort
, and try to pull again.
如果您知道您在 中修改了某些内容
abc_1.0.json
,并且需要将此修改保留在此文件中,请解决冲突:abc_1.0.json
在你的编辑器中打开- 寻找冲突标记(看起来像 :
<<<<< HEAD
,=====
, 的行>>>>> testing
) - 选择应该保留的版本
如果您知道当前合并并不重要,则可以运行
git merge --abort
,然后再次尝试拉取。