K
K
krll-k2014-07-18 15:50:51
git
krll-k, 2014-07-18 15:50:51

How to change a branch on a remote Git repository?

How to change a branch on a remote Git repository?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Entelis, 2014-07-18
@DmitriyEntelis

Here's how I did the renaming.
First, in your working tree, locally rename master to something else.
git branch -m master old-dev
Renaming a branch does work while you are on the branch, so there's no need to checkout something else.
Then, locally rename the maintenance branch (2.63-branch) to master:
git branch -m 2.63-branch master
Now, time to mess with the remote. Just in case you screw up, you might want to make sure you have a current backup. First, delete the remote's master:
git push origin :master
And now, give the remote your new master:
git push origin master:refs/heads/master
Update: When creating a new branch, the refs/heads/ prefix is ​​needed on the remote side. If the branch already exists (as master did above) only the branch name is required on the remote side.
... and your now-renamed old master:
git push origin old-dev:refs/heads/old-dev
Finally, delete the old name of your maintenance branch to prevent confusion:
git push origin :2.63-branch
Clients will now get the 'new' master branch when they pull.
stackoverflow.com/questions/7084273/renaming-remot...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question