git:gitcherry-pick后gitcherry的输出没有改变

标签 git git-cherry-pick git-cherry

我在 git 中有两个 Remote ,即“origin”和“upstream”。 origin 在某个时刻被 fork 到上游,并且自 fork 以来两者都进行了多次提交。现在我想将“上游”发生的许多(但不是全部)提交转移到“源”。所以我的操作顺序如下:-

1-从远程存储库获取所有更改并更新本地主控(我在主分支上):-

git fetch origin
git fetch upstream
git rebase origin/master

2- 列出本地 master 和上游 master 之间提交的差异:-

git cherry -v master upstream/master

看到之后我发现有很多带有(+)符号的提交:-

+ abcdabcdabcdabcdabcdabcdabcdabcdabcd First different commit
+ 123412341234123412341234123412341234 Second different commit
+ efabefabefabefabefabefabefabefabefab Third different commit
+ 567856785678567856785678567856785678 Fourth different commit
+ a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1 Fifth different commit

3-我对挑选第四次提交感兴趣,因此我继续执行以下命令(确保我首先位于分支主控上):-

git cherry-pick 567856785678567856785678567856785678

4- 此时,我再次执行 gitcherry,如步骤 2 中所列:-

git cherry -v master upstream/master

我预计输出会有所不同,因为第四次提交会有 (-)。但是,此命令后的输出仍然相同:-

+ abcdabcdabcdabcdabcdabcdabcdabcdabcd First different commit
+ 123412341234123412341234123412341234 Second different commit
+ efabefabefabefabefabefabefabefabefab Third different commit
+ 567856785678567856785678567856785678 Fourth different commit
+ a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1 Fifth different commit

我仔细检查了 master 中的日志,可以看到第四次提交已被添加。我还需要做些什么才能看到 gitcherry 输出的变化吗?我需要做什么才能正确区分 origin/masterupstream/master 之间的差异?

我在 Windows 版本 2.11.0.windows.1 上使用 git。

最佳答案

当精选的提交与您的分支发生冲突时,就会发生这种情况,因此您需要通过调整代码更改来解决它们。因此,gitcherry无法弄清楚新提交与其发起者相同,因此它在要应用的更改列表中显示原始提交。 This post倒是描述了情况。请注意,该帖子并不完全准确,如下面评论中所述。

关于git:gitcherry-pick后gitcherry的输出没有改变,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47053377/

相关文章:

eclipse - Cherry pick 到 Eclipse git 中的另一个分支

GIT 使用 gitcherry 和 format 显示 master 中缺少的分支的所有提交

git diff 仅显示修订版/分支 A 领先于修订版/分支 B

git - 恢复由于分离头而意外丢失的提交

git submodule update --remote vs git pull

git - 在 git cherry pick 之前是否需要一个新的分支?

Git cherry 选择一个提交并将其放在下面

git - IntelliJ 显示 diff 始终与相同的旧 git 提交进行比较

git - 如何使用 gitcherry 获取提交者电子邮件?

git - 'cherry' 在 git-cherry 中意味着什么?