Reputation: 2185
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?
Upvotes: 3
Views: 7692
Reputation: 33374
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.
Upvotes: 6
Reputation: 154846
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
.
Upvotes: 1