提示:解决冲突后,标记更正的路径

hint: after resolving the conflicts, mark the corrected paths

git 有时会给我这条关于冲突的消息(在恢复或选择时)

hint: after resolving the conflicts, mark the corrected paths

这是什么意思?

因为有些文件有冲突,你可以输入git status找出冲突的文件是什么,解决冲突后,就git commit -m sth log,最后git cherry-pick your-commmit-id 。查看详情 http://wiki.koha-community.org/wiki/Using_Git_Cherry_Pick#Resolve_conflicts

这意味着您需要明确告诉 Git 您已经解决了每个文件或文件夹(即路径)的冲突。

显示尚未解决的冲突列表:

git status

将冲突标记为已解决。

应该保留文件夹中的文件或所有文件,并解决所有冲突:

git add

应删除文件或文件夹:

git rm

下一步:

git commit

这...可能会令人困惑,并且对于 Git 2.34(2021 年第 4 季度),“git cherry-pick"(man) 给出的建议信息更加清晰:

当它要求最终用户解决提交冲突重播时,它现在(Git 2.34,2021 年第 4 季度)说:

  • 对于 git cherry-pick:
After resolving the conflicts, mark them with
`git add`/`rm <pathspec>`, then run
`git cherry-pick --continue`

You can instead skip this commit with `git cherry-pick --skip`.

To abort and get back to the state before `git cherry-pick`
run `git cherry-pick --abort`.
  • 对于 git revert:
After resolving the conflicts, mark them with
`git add`/`rm <pathspec>`, then run
`git revert --continue`

You can instead skip this commit with `git revert --skip`.

To abort and get back to the state before `git revert`
run `git revert --abort`.

参见 commit f172556 (22 Aug 2021) by ZheNing Hu (adlternative)
(由 Junio C Hamano -- gitster -- in commit 173368d 合并,2021 年 9 月 10 日)

cherry-pick: use better advice message

Mentored-by: Christian Couder
Mentored-by: Hariom Verma
Helped-by: Phillip Wood
Helped-by: Junio C Hamano
Signed-off-by: ZheNing Hu

"git cherry-pick"(man), upon seeing a conflict, says:

hint: after resolving the conflicts, mark the corrected paths 
hint: with `git add <paths>` or `git rm <paths>` 
hint: and commit the result with `git commit`.

As if running "git commit" to conclude the resolution of this single step were the end of the story.

This stems from the fact that the command originally was to pick a single commit and not a range of commits, and the message was written back then and has not been adjusted.

When picking a range of commits, and the command stops with a conflict in the middle of the range, however, after resolving the conflict and (optionally) recording the result with "git commit", the user has to run "git cherry-pick --continue" to have the rest of the range dealt with, "--skip" to drop the current commit, or "--abort" to discard the series.

Suggest use of "git cherry-pick --continue/--skip/--abort so that the message also covers the case where a range of commits are being picked.

Similarly, this optimization can be applied to git revert(man), suggest use of "git revert --continue/--skip/--abort so that the message also covers the case where a range of commits are being reverted.

It is worth mentioning that now we use advice() to print the content of GIT_CHERRY_PICK_HELP in print_advice(), each line of output will start with "hint: ".