Git:合并问题与 Git
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11527069/
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 : Merging Issues with Git
提问by Pawan
I am using git version 1.7.11.msysgit.0
我在用 git version 1.7.11.msysgit.0
I created a repository under GitHUB and added a file called as README.md with some text content .
我在 GitHub 下创建了一个存储库,并添加了一个名为 README.md 的文件,其中包含一些文本内容。
Later on , I have installed GIT Client , did a clone to get the server contents on to my machine .
后来,我安装了 GIT 客户端,进行了克隆以将服务器内容放到我的机器上。
Then I deleted the file README.md on to my local machine .
然后我将 README.md 文件删除到我的本地机器上。
Now when I do git commit , I get this error
现在,当我执行 git commit 时,出现此错误
praveenk@MSIN-BT-100 /d/workspace/MYTestRepo (master|MERGING)
$ git commit ;
U README.md
error: 'commit' is not possible because you have unmerged files.
hint: Fix them up in the work tree,
hint: and then use 'git add/rm <file>' as
hint: appropriate to mark resolution and make a commit,
hint: or use 'git commit -a'.
fatal: Exiting because of an unresolved conflict.
This is with git pull
:
这是与git pull
:
$ git pull;
U README.md
A One.txt
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'.
How to resolve these errors ?
如何解决这些错误?
回答by wadesworld
Do this:
做这个:
git merge --abort
git pull (to be sure you're up-to-date)
Now replace the contents of the README.md file with what you want it to say. If you don't want it at all, do git rm README.md
现在用你想要的内容替换 README.md 文件的内容。如果您根本不想要它,请执行 git rm README.md
Then if you replaced the contents, commit and push those contents with:
然后,如果您替换了内容,请提交并推送这些内容:
git add README.md
git commit -m "comment"
git push
回答by dorien
Try:
尝试:
git reset README.md
I had a similar issue and this was the only thing that solved it.
我有一个类似的问题,这是解决它的唯一方法。
回答by VonC
While a git reset
is a good solution, note that the warning message has now a better format (Git 2.1, August 2014)
虽然 agit reset
是一个很好的解决方案,但请注意警告消息现在具有更好的格式(Git 2.1,2014 年 8 月)
See commit d795216and commit c057b24by Jeff King (peff
):
见提交d795216并提交c057b24由杰夫·金(peff
):
The irregular line-wrapping makes this awkward to read, and it takes up more lines than necessary. Instead, let's rewrap it to about 60 characters per line.
The quotes around "commit
" are clunky; the user doesn't care that this message is a template with the command-name filled in.
不规则的换行使得阅读起来很尴尬,而且它占用了不必要的行数。相反,让我们将其重新包装为每行大约 60 个字符。
" commit
"周围的引号很笨重;用户并不关心这个消息是一个填充了命令名称的模板。
$ git commit
U foo
error: commit 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, or use
hint: 'git commit -a'.
fatal: Exiting because of an unresolved conflict.