Git:在合并期间无法进行部分提交(SourceTree)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/39616390/
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: cannot do a partial commit during a merge (SourceTree)
提问by Jan Drozen
After updating the SourceTree to it's latest version I am fighting with this issue. Assume following scenario:
将 SourceTree 更新到最新版本后,我正在解决这个问题。假设以下场景:
There are file A, Band Cunder the version control and there is just one branch. In my working copy, I make some changes to the file Aso it turns into a A'as well as the file Bto B'. Someone else in his working copy makes a change to the file C-> C'.
版本控制下有文件A、B和C,并且只有一个分支。在我的工作副本中,我对文件A进行了一些更改,使其变为A'以及文件B变为B'。他的工作副本中的其他人对文件C-> C'进行了更改。
I stage and commit my changes to the file B only. So I have a new revision: A, B', Cand working copy A', B', C.
我仅暂存并提交对文件B 的更改。所以我有一个新的修订:A, B', C和工作副本A', B', C。
The other one commits his changes, so he makes a revision A, B, C'and pushes it to the origin.
另一个提交了他的更改,因此他进行了修订A、B、C'并将其推送到原点。
And here it comes. When I perform the pull, I get some merge changes (the C'). And I want to commit a revision consisting of A, B', C'. I do not want to do now anything with the modified file A. However, the GIT, SourceTree resp., fails with:
它来了。当我执行拉取时,我会得到一些合并更改(C')。我想提交一个由A, B', C'组成的修订版。我现在不想对修改后的文件A做任何事情。但是,GIT 和 SourceTree 分别失败了:
fatal: cannot do a partial commit during a merge.
致命:在合并期间无法进行部分提交。
untill I stage or discard changes to the file A.
直到我暂存或放弃对文件A 的更改。
I am pretty sure the some previous version of SourceTree did not expose this behavior.
我很确定以前版本的 SourceTree 没有公开这种行为。
Update 2017/05
更新 2017/05
It appears in the most recent SourceTree version 2.0.20.1 this issue has been resolved. However, be sure you want to update to this version, because it contains lot of "bugs" (new features) I really dislike.
出现在最新的 SourceTree 版本 2.0.20.1 中,此问题已得到解决。但是,请确保您要更新到此版本,因为它包含许多我非常不喜欢的“错误”(新功能)。
回答by Arvin
fatal: cannot do a partial commit during a merge.
致命:在合并期间无法进行部分提交。
This indicates that your merge is still in progress, there could be some conflicts which you still need to resolve.
这表明您的合并仍在进行中,可能存在一些您仍需要解决的冲突。
Please select Conflictsfrom the drop down box as screenshot and you should be able to see a list of conflicted files with a triangle icon. Resolving these and then doing a commit should fix your problem.
请从下拉框中选择冲突作为屏幕截图,您应该能够看到带有三角形图标的冲突文件列表。解决这些问题然后提交应该可以解决您的问题。
This post should give a brief idea of how to configure and use an external tool to resolve merge conflicts - How to interactively (visually) resolve conflicts in SourceTree / git
这篇文章应该简要介绍如何配置和使用外部工具来解决合并冲突 -如何以交互方式(视觉)解决 SourceTree / git 中的冲突
If you still can't make up, you may stash your changes. Pull from origin and apply stash to fix the same.
如果您仍然无法弥补,您可以隐藏您的更改。从原点拉出并应用 stash 来修复它。
Edits
编辑
You can also automate all such operations using "custom action". One sample script to do a stash >> pull >> apply stash is copied below
您还可以使用“自定义操作”自动执行所有此类操作。下面复制了一个执行 stash >> pull >> apply stash 的示例脚本
git -c diff.mnemonicprefix=false -c core.quotepath=false stash save temp
git -c diff.mnemonicprefix=false -c core.quotepath=false fetch origin
git -c diff.mnemonicprefix=false -c core.quotepath=false pull origin <<local path goes here>>
git -c diff.mnemonicprefix=false -c core.quotepath=false submodule update --init --recursive
git -c diff.mnemonicprefix=false -c core.quotepath=false stash apply stash@{0}
回答by javaPlease42
The following answer to this questionworked for me.
这个问题的以下答案对我有用。
"You can manually delete .git/MERGE_HEADand Git won't be able to tell that you were just doing a merge. It will let you amend the previous commit with the changes in your index just like normal."
“您可以手动删除.git/MERGE_HEAD并且 Git 将无法判断您只是在进行合并。它可以让您像往常一样使用索引中的更改来修改先前的提交。”