Reputation: 2268
I have several branches in my repo - master, production, staging, other_stuff I want to set my production branch as master, and rename my master branch to master_legacy.
How can I do it? Actually I found guide, but I'm not sure, whether I can implement it here:
git checkout production
git merge -s ours master
git checkout master
git merge production
Upvotes: 1
Views: 2413
Reputation: 23711
Just follow these simple steps
git checkout master
git checkout -b master_backup
git checkout production
git branch -D master
git checkout -b master
git push -f origin master
Upvotes: 1
Reputation: 70
My suggestion would be to create the master_legacy branch from the current master branch, and then merge the production branch to master. Then you would have the state of the current master branch in the master_legacy branch, and all changes added to the production branch would be in the master branch.
Or is there some reason that you don't want to merge the production branch into master?
Upvotes: 1
Reputation: 1032
You can use git branch -m <oldBranch> <newBranch>
to rename a branch. In your case:
git branch -m master master_legacy
git branch -m production master
should do the trick.
Upvotes: 3