git 如何将develop分支重置为master
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18436680/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
how to reset develop branch to master
提问by trrrrrrm
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:
我有develop
&master
分支,我的develop
分支现在很乱,我想重置它并将其作为我的master
. 我不确定合并master
intodevelop
是否会使它们完全相同。尝试合并后,我遇到了很多冲突,我使用以下方法解决了它们:
git checkout develop
git merge origin/master
//got many conflicts
git checkout . --theirs
is this enough for develop
branch to be an identical copy to master
?
这足以让develop
branch 成为与 相同的副本master
吗?
Thanks
谢谢
回答by Tim Jarvis
if you just want them to be the same thing
如果你只是希望它们是一样的
then
然后
//from Develop and assuming your master is up to date with origin/master
git reset --hard master
回答by Amber
If you want to make develop
be identical to master
, the simplest way is just to recreate the pointer:
如果要使develop
与 相同master
,最简单的方法就是重新创建指针:
git branch -f develop master
Or, if you already have develop
checked out:
或者,如果您已经develop
签出:
git reset --hard develop 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:
但是请注意,这两个选项都将删除任何develop
不在master
. 如果这不行,您可以通过创建一个镜像master
的最新状态的提交来保留它:
git checkout develop
git merge --no-commit master
git checkout --theirs master .
git commit
回答by Shea Lavington
I'm a bit late to the party, however, after merging my dev branch into the master and pushing to the server, I do the following:
我参加聚会有点晚了,但是,在将我的 dev 分支合并到 master 并推送到服务器后,我执行以下操作:
git fetch
git fetch
git checkout development
git checkout development
git merge origin/master
git merge origin/master
git push
git push
The the dev branch is one commit ahead of the master branch, and other developers don't have to worry about all commits in the development branch being reset.
dev 分支比 master 分支早一次提交,其他开发者不必担心 development 分支中的所有提交都被重置。