我如何在Git的另一个分支上“覆盖”而不是“合并”分支? [英] How do I 'overwrite', rather than 'merge', a branch on another branch in Git?

查看:185
本文介绍了我如何在Git的另一个分支上“覆盖”而不是“合并”分支?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个分支,电子邮件分段 staging 是最新的一个,我不再需要电子邮件分支中的旧更改,但我不想删除它们。

所以我只想将 staging 的所有内容转储到电子邮件中以便它们都指向相同的提交。这可能吗?

解决方案

您可以使用'我们'的合并策略:

  $ git checkout staging 
$ git merge -s我们的email#合并分支,但使用我们的分支头


I have two branches, email and staging. staging is the latest one and I no more need the old changes in email branch, yet I don't want to delete them.

So I just want to dump all the contents of staging into email so that they both point to the same commit. Is that possible?

解决方案

You can use the 'ours' merge strategy:

$ git checkout staging
$ git merge -s ours email # Merge branches, but use our branch head

这篇关于我如何在Git的另一个分支上“覆盖”而不是“合并”分支?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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