我做了一件蠢事,结果引起了冲突。我解决了冲突,现在一切都好了(我也使用了mergetool)。
当我用git commit file.php -m "message"提交解析文件时,我得到了错误:
fatal: cannot do a partial commit during a merge.
我以前遇到过同样的问题,在commit中使用-a工作得很好。我认为这不是完美的方式,因为我不想提交所有的更改。我想用单独的注释单独提交文件。我该怎么做呢?为什么git不允许用户在合并后单独提交文件?对于这个问题,我找不到满意的答案。
Git commit -i -m 'merge message'不适合我。它说:
fatal:没有包含——include/——only的路径是没有意义的。
FWIW,我通过这个相关的问题来到这里,因为我得到了这样的信息:
fatal:你还没有结束你的合并(MERGE_HEAD存在)。
我还尝试了mergetool,它说没有文件需要合并。很困惑!所以MERGE_HEAD不在需要合并的文件中-??
最后,我用这个技巧只添加修改过的文件(不想添加树中的所有文件,因为我有一些我想保持不跟踪):
git ls-files -m |xargs git add
然后我终于(!)能够承诺并向上推。如果git能给你更好的提示,告诉你在这种情况下该怎么做,那就太好了。
我用一种完全不同的方法解决了这个问题,只使用了Xcode的源代码控制。
背景:另一个团队将更改推送到远程Git存储库(通过Beanstalk)。在我这边,.xcodeproj文件放在不同的目录下,没有进行更改。后来,当我试图提交时,我在Xcode中收到了一个树冲突错误。
由于使用Xcode几乎不可能纠正错误,所以我用从Git服务器下载的版本替换了.xcodeproj文件。结果……Xcode项目似乎清理了,但是所有来自损坏的Pull的更新都显示为我所做的更改,并被提交。
然而,当尝试提交时,我收到了同样的“致命:不能在合并期间进行部分提交”错误,这里讨论。
Here's how I solved the problem... (Now, understand that I'm a rookie programmer, so I could lack some understanding... but my ignorance led me to find another way to do this.) First, I Cloned my master Branch into a secondary Branch and switched to that branch. Then I created a Working Copy and placed the directory to that working copy outside of the original project directory. (I don't know if this was necessary, but its what I did as I read other troubleshooting techniques.) Then I switched branches to the master, where I realized all my Staged files (changes to Commit) were gone. To make sure all the files were updated to the latest changes made by the other party, I created a new branch called ThirdBranch, which duplicated all files, Pushed it to the Git Server and let Beanstalk compare my server version of the master branch to the ThirdBrach branch I just Pushed (line by line), and all the changes by the other party were present on my Xcode. This meant that my master repository and the Git master repository were the same, which verifies that I solved the problem using Xcode, only.
不要问我是怎么做到的,除了我刚才描述的……当然也能填补我遗漏的空白。我是新手,也不是什么都懂。也许一个有经验的程序员可以将不相关的信息从相关信息中分离出来,并更清楚地重新创建这种技术,这也是我发布这篇文章的部分原因。
这是对重复问题的重复回答:失败的Xcode Git合并卡住了
有时在合并过程中,如果出现冲突,并且存在需要手动解决的增量。在这种情况下,修复手动解决文件提到。
如果你提出,
git status Lib/MyFile.php
您将看到如下输出
On branch warehouse
Your branch and 'origin/warehouse' have diverged,
and have 1 and 1 different commits each, respectively.
(use "git pull" to merge the remote branch into yours)
All conflicts fixed but you are still merging.
(use "git commit" to conclude merge)
Changes to be committed:
modified: Lib/MyFile.php
因为您已经执行了提交,所以您只需要发布
git commit
你的承诺将会毫无问题地完成。