[英]how to reset develop branch to master
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
.我有develop
和master
分支,我的develop
分支现在很乱,我想重置它并将其作为我的master
的副本。 i'm not sure if merging the master
into develop
will make both of them identical.我不确定将master
合并到develop
是否会使它们完全相同。 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
is this enough for develop
branch to be an identical copy to master
?这足以让develop
分支成为与master
相同的副本吗?
Thanks谢谢
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
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
.但是请注意,这两个选项将摆脱任何历史的develop
有其不在master
。 If that isn't okay, you could preserve it by instead creating a commit that mirrored master
's latest state:如果这不行,您可以通过创建一个反映master
最新状态的提交来保留它:
git checkout develop
git merge --no-commit master
git checkout --theirs master .
git commit
git reset HEAD~
If all else fails, you can delete your current branch and just directly recreate it from master
.如果所有其他方法都失败了,您可以删除当前分支并直接从master
重新创建它。
git branch -D develop
git checkout master
git checkout -b develop
For example making staging
branch identical to develop
, one could simply recreate the pointer:例如,使staging
分支与develop
相同,可以简单地重新创建指针:
First make sure your local develop branch is up to date with origin/develop
by running: git checkout develop && git pull origin develop
首先通过运行以下命令确保您的本地开发分支与origin/develop
同步: git checkout develop && git pull origin develop
Then checkout your target branch (in this case staging
) git checkout staging
然后结帐您的目标分支(在这种情况下staging
) git checkout staging
And finally but not least reset target branch git reset --hard develop
最后但并非最不重要的是重置目标分支git reset --hard develop
Push changes by brute force (git will complain because local pointer have different address) git push -f
通过蛮力推送更改(git 会抱怨,因为本地指针具有不同的地址) git push -f
And that would be pretty much it!就这样吧!
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 checkout development
git merge origin/master
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 分支中的所有提交都被重置。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.