【问题标题】:Git Refresh Merge Points Both Branches to Most Recent CommitGit Refresh 将两个分支合并到最近的提交
【发布时间】:2014-04-24 16:56:39
【问题描述】:

我的团队在 Windows 中使用带有“msysgit”的 Bitbucket 和 Eclipse 的 git 插件来管理 git repo。我们通常有一个 master 和 2 或 3 个可以相互依赖的特性分支。我们遇到了这样一种情况,在我们从 'feature-1' 刷新 'feature-2' 后,'feature-1' 和 'feature-2' 都指向合并的提交。这会污染“feature-1”,因为提交不应该在“feature-1”中。请看下图。

feature-1   --0--1--\--2--3--4--\
                     \ create    \ refresh
feature-2             \--5--6--7--\---

'feature-1' 存在。 'feature-2' 被创建和处理,而'feature-1' 被处理。从“feature-1”到“feature-2”的合并完成。

git checkout feature-2
git merge feature-1
git push

现在“feature-1”和“feature-2”指向同一个提交哈希,“feature-1”包含来自“feature-2”的提交。

有时,此工作流程的行为符合我的预期,其中“feature-2”包含来自“feature-1”的所有提交,而“feature-1”则保持在自己的位置。偶尔,我们会体验到我所报告的内容。

有人知道发生了什么吗?我觉得我缺少一些基本概念。

【问题讨论】:

    标签: git merge bitbucket


    【解决方案1】:

    唯一的办法:

    git checkout feature-2
    git merge feature-1
    

    最终将feature-1feature-2 都指向同一个提交是如果feature-2 没有任何提交,因为它要么从feature-1 分支出来,要么自上次合并以来 - 这将导致在快进合并中,它只是将feature-2 的指针移动到与feature-1 相同的提交。即使是这样,两个分支上的未来提交也会再次分歧,因为它们仍然是独立的指针,即使它们在一段时间内指向同一个东西。

    完成合并后,合并到分支(在这种情况下为 feature-2)似乎在其历史记录中将所有 feature-1 提交到合并点是正常的 - 这就是您想要的. feature-1 不应显示来自 feature-2 的提交,除非有人无意中进行了相反的合并(例如 git checkout feature-1; git merge feature-2)。您应该能够看到 gitk --all 发生了什么。

    【讨论】:

      猜你喜欢
      • 2012-03-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-07-17
      • 2016-03-23
      • 1970-01-01
      • 1970-01-01
      • 2012-08-31
      相关资源
      最近更新 更多