用另一个分支替换主人 [英] Replacing master with another branch

查看:148
本文介绍了用另一个分支替换主人的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有三个分行:

  master 
old
test

Master和Old完全相同, test 整个新项目。我想用测试分支替换主分支,并且测试分支(和旧分支)保持不变。我怎么能这样做?



我一直在想:

  git checkout test 
git merge -s我们的master
git checkout master
git合并测试

这是安全的方式吗?

这是一个使用我们的合并策略的实现。基本上,这将覆盖主测试。

  git checkout test 
git merge -s我们的主人
git checkout master
git合并测试

结果应该是你的主人现在基本上测试了。 任何数量的负责人,但合并的结果总是当前的分支负责人。它是用来取代旧分支的旧发展历史

参考



git-merge


I have three branches:

master
old
test

Master and old are exactly the same, and test holds all my changes and the whole new project. I want to replace master branch with test branch, and test branch (and old branch) to remain unchanged. How can I do this?

I've been thinking about:

git checkout test
git merge -s ours master
git checkout master
git merge test

Is this the safe way to do this?

解决方案

Example

Here is an implementation using ours merge strategy. Essentially, this will overwrite master with test.

git checkout test
git merge -s ours master
git checkout master
git merge test

The result should be your master is now essentially test.

Merge Strategy

ours - This resolves any number of heads, but the result of the merge is always the current branch head. It is meant to be used to supersede old development history of side branches

Reference

git-merge

这篇关于用另一个分支替换主人的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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