1

In our Git repository we have a few merges from branches that should have been merged with --no-ff but were not. These merges were made a long time ago.

Is there any way to force/insert a commit as if we were running those old merges with the --no-ff argument?

One of the supers on the project enjoys GitHub's network view and wanted to be able to see the individual branches, which are all merged into one line when a fast-forward occurs.

4

1 回答 1

2

如果您不介意拥有一个新的主/主分支(或覆盖旧的分支 - 但请记住,重写已发布的历史记录是不好的),您可以简单地重新创建合并,如果您还记得,当它们/应该有制作:

  1. 签出第一个被遗忘/不存在/错过的合并:

    git checkout -b new_master $commit_before_merge
    
  2. 合并旧的提交。如果您想要正确的合并消息(包括原始分支名称),您可能需要临时重新创建旧分支,或手动编辑消息。

    git merge $head_commit_of_old_branch
    
  3. 然后,您将不得不使用cherry-pickrebase将提交从原始主分支复制到新的“合并”分支。(带有提交范围的 Cherry-pick 需要最新版本的 Git)

    git cherry-pick $commit_before_merge..$commit_before_next_merge
    
  4. 返回第 2 步并重复,直到您对历史感到满意为止。

注意。首先在本地克隆中进行备份和测试。

于 2012-07-25T09:44:53.567 回答