如何避免git rebase杀死merge commit? [英] How to avoid git rebase killing merge commits?

查看:400
本文介绍了如何避免git rebase杀死merge commit?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

给出以下 git 历史记录:

  CI起源/主
/
ABFGH master
\ /
DE分行-B

我想在我的本地 master 分支上重新分配 origin / master ,但我想保留合并提交 G 。当我在 master 时尝试简单地执行 git rebase origin / master 时,它压扁了 D。 .E 作为 G 并且通过 E 的提交信息来提交,因此历史记录有一次合并失败了。有没有办法保留这个合并,同时仍然获得rebase?为了清楚起见,我的预期结果是:

  ABCIFGH master 
\ /
D ---- -e branch-b


解决方案

添加 - 将保存到您的rebase命令。如果您的合并中存在冲突解决方案,请将递归他们的策略作为参数添加。

Given the following git history:

    C-I    origin/master
   /
A-B-F-G-H  master
 \   /
  D-E      branch-b

I want to rebase my local master branch on top of origin/master, but I want to preserve the merge commit G. When I tried simply doing a git rebase origin/master while at master it squashed D..E as G and committed that with the commit message of E, so the history that there was a merge was lost. Is there some way of preserving this merge while still getting the rebase? For clarity, my intended result is:

A-B-C-I-F-G-H  master
 \       /
  D-----E      branch-b

解决方案

Add --preserve-merges to your rebase command. In case there were conflict resolutions in your merge, add 'recursive theirs' strategy as a parameter as well.

这篇关于如何避免git rebase杀死merge commit?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆