问题标签 [git-cherry-pick]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
3 回答
253 浏览

git - 樱桃选择是否应用更改或尝试合并整个文件的内容?

我正在阅读这篇关于樱桃采摘的文章,那里有以下图片:

在此处输入图像描述

然而,这张照片对我来说似乎是一种误导。从我的简单测试来看,似乎不仅仅是差异,而是整个文件内容都被合并了。这是实验:我有这个提交图:

CommitA中有以下内容file.txt

提交B有小的变化:

提交C有小的变化:

所以现在我正在尝试使用cherry-pick重播B提交,C

我遇到了冲突,

如果仅应用更改,则不应该存在。由于我在提交中没有触及l2线C,它应该可以顺利应用。我对吗?

0 投票
2 回答
3693 浏览

git - Git cherry pick 从分支 A 提交到 B

我有两个分支developmaster。假设master落后大约 20 次提交。我只想将其中一个提交(07f5722)从develop合并到master。我怎样才能做到这一点?

如何在 git 中合并特定提交以及如何在 Git 中将特定提交从一个分支合并到另一个分支?两者都说要使用git cherry-pick,而没有过多解释您应该如何使用它。我也没有真正遵循手册页中的示例。

我尝试执行以下操作:

但收到有关樱桃采摘为空的消息:

git cherry-pick not working的答案表明这意味着cherry-pick 是没有实际更改的无操作。好的,那么我如何获得更改?

注意:我的问题与git cherry-pick not working几乎相同。但是,我想知道如何完成我打算做的事情,而不是为什么我尝试的命令特别失败。


我必须使用的命令序列是:

0 投票
1 回答
86 浏览

git - Merge folder from one branch into another with git

I'm working with two branches in a git repository.

They are rc and dev.

I have a folder in dev src/ that I need to merge into rc.

I've tried to use git cherry-pick --strategy=recurisve --strategy-option=theirs <commit> method by first creating a shell script to add a new line to all the files in the directory to trigger a change with git.

The script was as follows:

What I did not realize is that git cherry-pick is only going to take the recognized changes vis-a-vis the aforementioned newlines.

Aside from just copying the folder over into a branch of rc and then creating a commit and merging, what are my options to push my changes that I've been working on in dev for two weeks into the rc branch.

I understand that the way I have been developing and using git is probably inappropriate and not intended use.

Ideally, I'd like to create a patch file using the diff on the two branches subfolders src/ and apply it. Though, I'm not sure how to execute this approach.

0 投票
1 回答
794 浏览

git - 挑选特定文件的所有提交历史记录

假设我想挑选回购的特定文件的完整提交历史,但回购有多个文件并且提交甚至不是,即第一次提交是我想要挑选的特定文件,第二次和第三次是到其他一些,第四个到特定文件等等..

在这种情况下,我怎么能在该特定文件的一个镜头中挑选所有提交,不包括对其他文件所做的提交..

我知道,

上面的命令不起作用,因为它会挑选我也想排除的其他提交..

所以我的问题是,有没有办法在一个命令中完成我的要求?

0 投票
0 回答
1125 浏览

git - 手动“合并”的樱桃采摘

如何使用cherry-pick 从另一个分支获取提交,让 git 检测哪些文件已更改,然后手动合并它(如使用 mergetool)?可能吗?

0 投票
1 回答
69 浏览

git - Cherry-pick 此提交 - 但将补丁应用于不同名称的文件

最初有branchA:fileA. 然后在 中branchBfileA分成两个分量,fileAfileB。然后在branchA,fileA中进行了编辑。我想把这个变化挑选成branchB; 问题是,在那个分支中,补丁应该应用于fileB,而不是fileA,并且 git 似乎无法通过简单git cherry-pick <sha1>的 from来解决这个问题branchB

我想挑选的提交只涉及fileA. 有没有办法可以强迫 git 将它应用到 git 上fileB

我相信这种情况很常见 -branchB例如,想象一个类层次结构添加另一个层。

0 投票
2 回答
654 浏览

git - Git 樱桃挑选范围

我怎样才能挑选提交C4C5

GitTree

我试过git cherry-pick C4..C5了,但我只得到C4. 我想我真的不明白这个范围是如何工作的。

0 投票
1 回答
370 浏览

git - Git合并/樱桃选择一个分支的所有提交

设想:

描述:

  1. 创建仓库
  2. 创建和签出分支 dev
  3. 创建并签出分支 feature1 .. 实现该功能
  4. 结帐开发并合并功能1,删除功能1
  5. 结帐主合并开发
  6. 创建tagV1(将交付给客户)
  7. 结帐开发
  8. 创建并签出分支 feature2 .. 实现该功能
  9. 结帐开发并合并功能2,删除功能2
  10. 结帐主合并开发
  11. 创建 tagV2(将交付相同或不同的客户)
  12. 结帐开发
  13. 创建并签出分支 fixForV1 .. 实施修复
  14. 结帐开发并合并 fixForV1
  15. ???

15… 我们需要合并 tagV1 和 fixForV1 上的提交(不包括 feature2 上的提交)。合并后,我们将创建一个新标签 tagV1_1 并将其交付给客户。

我知道我可以通过挑选 {hash of first commit on fixForV1} ^..{hash of last commit on fixForV1} 来实现这一点。有没有更好的方法来做到这一点?

0 投票
1 回答
3800 浏览

git - Cherry-pick 和 patch apply 有什么区别?

我知道 git cherry-pick 和 git apply terminalogies。但是今天我遇到了一些问题。我通过使用两个修订版的差异来应用一个补丁。我使用了以下命令:

git diff 头> diff.patch

git 应用 diff.patch

一个文件的补丁应用失败。

然后我只是尝试挑选commit-id2。樱桃采摘成功。

可能是什么原因?任何人都想对此有所了解。

0 投票
3 回答
47827 浏览

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

git 有时会在冲突时给我这个消息(在恢复或樱桃采摘期间)

这是什么意思?