1

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
Daniel Chepenko
  • 2,229
  • 7
  • 30
  • 56
  • 1
    Possible duplicate of [Change the current branch to master in git](http://stackoverflow.com/questions/2763006/change-the-current-branch-to-master-in-git) – Julien Lopez Oct 18 '16 at 07:56

3 Answers3

3

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.

Pan Long
  • 1,024
  • 1
  • 9
  • 16
1

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?

Spacy
  • 70
  • 1
  • 8
1

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
Deepak Mahakale
  • 22,834
  • 10
  • 68
  • 88