简体   繁体   English

如何将远程开发分支重置为master

[英]How to reset develop branch on remote 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 then push it to the server. 我有开发和主分支,我的开发分支现在很乱,我想重置它,并将其作为我的主副本,然后将其推送到服务器。

I'm not sure if merging the master into develop will make both of them identical. 我不确定将主人合并到开发中是否会使两者完全相同。 after trying 在尝试之后

git branch -f develop master
git checkout develop

I get the following message 我收到以下消息

Switched to branch 'develop' Your branch is behind 'origin/develop' by 34 commits, and can be fast-forwarded. 切换到分支“开发”您的分支在34个提交后面的'origin / develop'后面,并且可以快速转发。 (use "git pull" to update your local branch) (使用“git pull”更新本地分支)

I want to update the remote too.. how do I do this? 我也要更新遥控器..我该怎么做? how do I get around all this 我怎么解决这一切

Please note that this will rewrite history and anyone else that is working off of an old copy of the origin's develop branch will need to update in a similar fashion. 请注意,这将重写历史记录 ,其他任何正在处理原始开发分支的旧副本的人都需要以类似的方式更新。 Otherwise things will get very sloppy. 否则事情会变得非常草率。

# Delete your local develop
git checkout master
git branch -D develop

# Recreate your local develop, based on origin's master
git pull origin master
git checkout -b develop

# Push and overwrite the sloppy develop on the origin
git push origin develop --force

This is what I would do: 这就是我要做的:

git checkout develop
git reset --hard master
git push --force origin develop

The commands you mentioned should also work, you are just missing the push. 你提到的命令也应该有效,你只是错过了推动。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM