简体   繁体   中英

How do I move origin/master to new branch?

I somehow managed to get some experimental features in my master branch at some point in the past which got pushed out to origin. My local master branch doesn't have the experimental features, so I'm going to force push it out. I don't want to lose the experimental changes, so is there a way I can move origin/master (or copy it) to a new branch before I force push my local master out to origin?

git checkout origin/master
git branch -b master_with_experiments
git push origin master -f

Or do cherry picks of those commits with git cherry-pick <sha1> to another branch and then force push master.

Or do an interactive rebase and rearrange commits as you want.

Sure, just use git branch experimental master to save your current master to a local branch. Then restore the master to the desired state and push it to the server. Finally, when you want to share the experimental branch with others, push it as well with git push origin experimental .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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