How to rename master branch and make another branch as master?

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

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.


只要按照这些简单的步骤

git checkout master
git checkout -b master_backup
git checkout production
git branch -D master
git checkout -b master
git push -f origin master

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?

链接地址: http://www.djcxy.com/p/43562.html

上一篇: 在Git diff commit范围中的点“...”?

下一篇: 如何重命名主分支,并使另一个分支为主?