如何将开发分支重置为母版 [英] how to reset develop branch to master
问题描述
我有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
?
谢谢
推荐答案
如果要使develop
与master
相同,最简单的方法就是重新创建指针:
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屋!