如何将开发分支重置为母版 [英] how to reset develop branch to master

查看:82
本文介绍了如何将开发分支重置为母版的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有develop& master分支,我的develop分支现在很凌乱,我想重置它并将其作为我的master的副本.我不确定将master合并到develop是否会使它们两者相同.尝试合并后,我遇到了许多冲突,我使用以下方法解决了这些问题:

I have develop & master branches, my develop branch is messy now and i would like to reset it and make it as a copy of my master. i'm not sure if merging the master into develop will make both of them identical. after trying to merge i got many conflicts i solved them using:

git checkout develop
git merge origin/master
//got many conflicts
git checkout . --theirs

这足以使develop分支成为与master相同的副本吗?

is this enough for develop branch to be an identical copy to master ?

谢谢

推荐答案

如果要使developmaster相同,最简单的方法就是重新创建指针:

If you want to make develop be identical to master, the simplest way is just to recreate the pointer:

git branch -f develop master

或者,如果您已经签出develop:

Or, if you already have develop checked out:

git reset --hard develop master

但是请注意,这两个选项都将摆脱develop所具有的任何历史记录,而该历史记录不在master中.如果这样做不行,则可以通过创建反映master最新状态的提交来保存它:

Note however that both of these options will get rid of any history that develop had which wasn't in master. If that isn't okay, you could preserve it by instead creating a commit that mirrored master's latest state:

git checkout develop
git merge --no-commit master
git checkout --theirs master .
git commit

这篇关于如何将开发分支重置为母版的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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