有时候在撤销或挑选提交时,git会给我一个冲突的提示信息
hint: after resolving the conflicts, mark the corrected paths
这是什么意思?
有时候在撤销或挑选提交时,git会给我一个冲突的提示信息
hint: after resolving the conflicts, mark the corrected paths
这是什么意思?
这意味着您需要明确告诉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
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 2.34(2021年第四季度)中,“git cherry-pick
”(man)给出的建议信息更清晰了:
当它要求用户解决提交的冲突回放时,现在(Git 2.34,2021年第四季度)会说:
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`.
请查看提交 f172556(2021年8月22日)由ZheNing Hu(adlternative
)完成。
(于2021年9月10日由Junio C Hamano -- gitster
--在提交 173368d中合并)
cherry-pick
: 使用更好的建议信息指导者:Christian Couder
指导者:Hariom Verma
协助者:Phillip Wood
协助者:Junio C Hamano
签署者: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 ofGIT_CHERRY_PICK_HELP
inprint_advice()
, each line of output will start with "hint: ".
git status
中除了changelog.md文件外没有其他文件显示,但我确定提交中除了changelog之外还有其他更改时,问题出在哪里? - Gobliinsgit add .
我就可以标记一个冲突为已解决状态了吗? - Richgit add file-which-had-conflicts
-> @Richgit添加有冲突的文件
- Nick Volynkin