如何覆盖 git 合并中的合并基础?

How can I override the merge-base in a git merge?

我的存储库有精选记录为合并。它抛出 git 的合并基础选择。是否可以指定合并基础?如果是,怎么做?

示例:f 是从 A 的 master 分支出来的。C 被精心挑选到 f,但错误地承诺与 K 和 C 作为父级合并。

A-B-C   master
\   \  
 K---C'-L   f

将 f 合并到 master 时 git 会发现 C 是最佳共同祖先并将其用作 Base。由于 B 包含在 Base 中,但在 f 中丢失,它将被合并撤销。使用 A 作为基础将给出正确的合并。

编辑: 排除下面询问的计划 B。所以,希望有人能回答:How can I specify the merge-base in a git merge?


编辑,B 计划:通过使用 tfs-git 从两个具有 cherry-pick-workflow 的 tfs-branches 获取,存储库已变成这样。一个变更集的 "Merge selected range" 在 git 中显示为完全合并。另一种解决方案是以某种方式配置 git-tfs 以不创建合并提交。 (停止为所有人挑选樱桃是不可取的。)

我认为问题是"cherry-picking"(以Git方式)似乎是没有功能或planned workflow团队基础服务器版本控制。


git的"cherry-pick"命令适用"the change introduced by the [given] commit[s] at the tip of the [...] branch and create[s] a new commit with [those] change[s]."(http://git-scm.com/docs/git-cherry-pick)

TFSVSC 没有 "cherry-picking" 命令但可以执行 "Merge [a] selected range" 或 "partial merge" 将指定的(后续)变更集合并到不同分支上的新变更集(http://blogs.msdn.com/b/dstfs/archive/2009/05/04/partial-merges-in-tfs-a-guide.aspx).

这就是 git-tfs 似乎达到极限的地方(在撰写本文时)- Invalid selective merges instead of cherry picks。 (目前)似乎没有将部分合并转换为相应的 git-cherry-picks 的故障安全方法,其中 git-merge 由于 Git 基于快照的差异而提供错误的结果(因此需要一个依赖树)与基于变更集的 TFS 相比。


我目前认为您必须等到 git-tfs 问题得到解决,或者在 git-存储库中进行挑选。另一种方法可能是检出 tfs-repository 并将其提交到 git-repo,但这会在传输过程中消除您的提交历史。

How can I specify the merge-base in a git merge?

有移植物:

echo $(git rev-parse tip1 mybase) >>.git/info/grafts
echo $(git rev-parse tip2 mybase) >>.git/info/grafts

git checkout tip1
git merge tip2

rm .git/info/grafts

edit from comment: with annotated tags, specify ^{} at the end of your references, tip1^{} 等,让 rev-parse 追踪并打印提交的 ID 而不是对标签的 ID 感到满意。