gpt4 book ai didi

git - 挑选一系列提交不起作用,但个别挑选工作

转载 作者:行者123 更新时间:2023-12-04 02:33:20 26 4
gpt4 key购买 nike

我在挑选一系列提交时遇到问题,并且不断发生冲突,无法弄清楚问题出在哪里。冲突不应该发生,因为提交是精心挑选的,添加/修改了接收分支中不存在的代码。
演练:
我挑选的提交来自一个名为 FeatureX 的分支。 ,并且提交看起来像这样:

>> git log --oneline

cbd0d94ca312 (HEAD -> FeatureX) Version 6
e1da344f20b7 Version 5
a9875369a8e4 Version 4
44d7975d975f Version 3
6955a667be84 Version 2
c7c70076c435 Version 1
现在,我有另一个分支叫 MainCode ,我想从 FeatureX 中挑选上述提交分支。如果我单独挑选它们:
>>git cherry-pick c7c70076c435
[MainCode 7850ed1c4a4d] Version 1
Date: Sat Jun 13 19:59:04 2020 -0700
2 files changed, 321 insertions(+), 1 deletion(-)
create mode 100644 STHelper.cs

>>git cherry-pick 6955a667be84
[MainCode df98023a9ac9] Version 2
Date: Tue Jun 16 15:36:24 2020 -0700
1 file changed, 68 insertions(+), 15 deletions(-)

>>git cherry-pick 44d7975d975f
[MainCode beede732db3f] Version 3
Date: Tue Jun 23 14:34:27 2020 -0700
1 file changed, 104 insertions(+), 23 deletions(-)

>>git cherry-pick a9875369a8e4
[MainCode 77664b1d36c2] Version 4
Date: Wed Jul 8 21:25:27 2020 -0700
1 file changed, 25 insertions(+), 15 deletions(-)

>>git cherry-pick e1da344f20b7
[MainCode 8eb1c3cf9828] Version 5
Date: Fri Jul 10 03:39:47 2020 -0700
1 file changed, 67 insertions(+), 19 deletions(-)

>>git cherry-pick cbd0d94ca312
[MainCode a07e9f4dbed9] Version 6
Date: Fri Jul 10 14:28:10 2020 -0700
3 files changed, 174 insertions(+), 35 deletions(-)
create mode 100644 config_debug.xml
...它工作正常。但是,如果我尝试将它们一起挑选......
>>git cherry-pick c7c70076c435^..cbd0d94ca312
error: could not apply 6955a667be84... Version 2
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 status
On branch MainCode
Cherry-pick currently in progress.
(fix conflicts and run "git cherry-pick --continue")
(use "git cherry-pick --abort" to cancel the cherry-pick operation)

Unmerged paths:
(use "git add/rm <file>..." as appropriate to mark resolution)
deleted by us: STHelper.cs

no changes added to commit (use "git add" and/or "git commit -a")
……有冲突。我也尝试使用 their更改(即从 FeatureX 分支更改)以尝试解决冲突...
>>git cherry-pick c7c70076c435^..cbd0d94ca312 --strategy=recursive -X theirs
error: could not apply 6955a667be84... Version 2
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'
......但它仍然不起作用。
有人可以告诉我这里有什么问题吗?
[编辑] 我在 Windows 上使用 cmd.exe 作为 shell。

最佳答案

这是一个 shell 问题:如评论中所述,您正在使用 cmd.exe ,其中^是转义字符
(例如,参见 ss64.com 上的此链接:Escape characters at the Windows command line)。
您的输入字符串:

c7c70076c435^..cbd0d94ca312
变成:
c7c70076c435..cbd0d94ca312
第一次提交被跳过。

如果你坚持使用 cmd.exe :使用 ~1 (正如@LasseVKarlsen 建议的那样)或 ^^而不是普通的 ^ :
git cherry-pick c7c70076c435^^..cbd0d94ca312

关于git - 挑选一系列提交不起作用,但个别挑选工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62950272/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com