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

问题描述 投票:0回答:3

git 有时会向我提供有关冲突的消息(在恢复或樱桃选择期间)

hint: after resolving the conflicts, mark the corrected paths

这是什么意思?

git git-merge git-revert git-cherry-pick git-merge-conflict
3个回答
57
投票

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

1。查看尚未解决冲突的文件列表

git status

2。将每个文件标记为已解决

解决文件中的冲突后,将其添加以标记冲突已解决:

git add file-which-had-conflicts

如果您想删除文件而不是解决冲突,请使用

git rm
进行操作。不过,这种情况很少见。

git rm file-which-had-conflicts

3.继续进行变基/合并/其他操作

git rebase --continue
git merge --continue
git cherry-pick --continue

5
投票

因为有些文件有冲突,你可以输入

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


1
投票

这......可能会令人困惑,而在 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(2021 年 8 月 22 日),作者:ZheNing Hu (

adlternative
)
(由 Junio C Hamano --
gitster
--
合并于 commit 173368d,2021 年 9 月 10 日)

cherry-pick
:使用更好的建议消息

导师:Christian Couder
指导者:Hariom Verma
帮助者:菲利普·伍德
帮助者:Junio C Hamano
签字人:胡哲宁

git cherry-pick
man,看到冲突后说:

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`.

仿佛运行“

git commit
”来结束这一步的解决就是故事的结局。

这是因为该命令最初是选择一个single提交而不是range提交,并且消息是当时写的并且尚未调整。

当选择提交的范围时,命令会因范围中间的冲突而停止,但是,在解决冲突并(可选)用“

git commit
”记录结果之后,用户必须运行“
git cherry-pick --continue
”处理其余范围,“
--skip
”删除当前提交,或“
--abort
”放弃该系列。

建议使用“

git cherry-pick --continue/--skip/--abort
”,以便消息也涵盖正在选择一系列提交的情况。

同样,此优化可以应用于

git revert
(man),建议使用“
git revert --continue/--skip/--abort
”,以便该消息也涵盖正在恢复一系列提交的情况。

值得一提的是,现在我们使用

advice()
来打印
GIT_CHERRY_PICK_HELP
print_advice()
的内容,每行输出都会以“hint:”开头。


git cherry-pick
(man)
git rebase -i
(man)会话期间调用丢失了作者信息,该信息已使用Git 2.44(2024年第一季度)进行更正,在2.44之前最后.

请参阅 Vegard Nossum (vegard)

commit e4301f7(2024 年 2 月 2 日)。
(由 Junio C Hamano --
gitster
--
合并于 commit c036a14,2024 年 2 月 14 日)

sequencer
:取消设置“exec”命令的
GIT_CHERRY_PICK_HELP

帮助者:Phillip Wood
签署人:Vegard Nossum

在 rebase 计划中将“

git cherry-pick
(man) 作为 x 命令运行会丢失原始作者信息。

要解决此问题,请取消设置“exec”命令的

GIT_CHERRY_PICK_HELP

© www.soinside.com 2019 - 2024. All rights reserved.