简体   繁体   English

“git cherry-pick”添加“Conflicts:”行来提交消息

[英]“git cherry-pick” adds “Conflicts:” line to commit message

Whenever I use git cherry-pick and there are conflicts, after resolving the conflicts and running git cherry-pick --continue , the commit message has an added Conflicts: section, like so: 每当我使用git cherry-pick并且存在冲突时,在解决冲突并运行git cherry-pick --continue ,提交消息会添加一个Conflicts:部分,如下所示:

<The original commit message>

Conflicts:
    <path of first file that had a conflict>
    ...
    <path of last file that had a conflict>

# The usual comment with instructions

The Conflicts: section is not commented out, so if left unchanged, it becomes a part of the actual commit message of the cherry-picked commit. Conflicts:部分未被注释掉,因此如果保持不变,它将成为樱桃挑选提交的实际提交消息的一部分。

So, two questions about this: 那么,有两个问题:

  1. Why is this section useful at all? 为什么这部分有用呢? If I resolved the conflicts, why is the fact that they existed relevant? 如果我解决了冲突,为什么他们存在相关的事实呢?

  2. Is there a way to disable this behaviour? 有没有办法禁用这种行为? I find it annoying to have to delete that section manually every time. 我觉得每次都要手动删除该部分很烦人。

EDIT : Since a comment suggests that the behaviour may be dependent on the version of git: I'm using git 2.1.4, which is the version present in Debian stable's repositories. 编辑 :由于评论表明行为可能依赖于git的版本:我正在使用git 2.1.4,这是Debian stable的存储库中的版本。

For your questions: 对于你的问题:

  1. It mainly caused there still have conflicts. 这主要是因为还存在冲突。 You can use git status to check. 您可以使用git status进行检查。 If there have conflicts, you should modify and save the conflict files, then use git add . 如果存在冲突,则应修改并保存冲突文件,然后使用git add . and git commit . git commit Also you can update git to latest version. 您也可以将git更新到最新版本。

  2. Yes, you can use -X to solve the conflicts automatically. 是的,您可以使用-X自动解决冲突。 Such as git cherry-pick SHA -X [ours|theirs] . 比如git cherry-pick SHA -X [ours|theirs] ours means to keep changes from current branch, theirs means keep changes from the SHA. ours意思是保持对当前分支的更改, theirs意思是保持对SHA的更改。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM