I have 2 git branches: master and experimental.
Experimental became good, I want to make it the master. I figured I would rename to shuffle things around, but here is what I got:
nutebook:Stuff nathan$ git remote rename master old error: Could not rename config section 'remote.master' to 'remote.old'
I use GitHub and Git-Tower.
To be precise, renaming a remote branch is not direct – you have to delete the old remote branch name and then push a new branch name to the repo. Step 2: Reset the upstream branch to the name of your new local branch by running git push origin -u new-branch-name .
Rename your remote branchFrom the branches page of your repository, you can rename the branch by clicking the little pencil icon. GitHub will automatically update open Pull Requests.
Renaming a remote repositoryUse the git remote rename command to rename an existing remote. The git remote rename command takes two arguments: An existing remote name, for example, origin. A new name for the remote, for example, destination.
The following is a guide to rename your master branch. It will work just as easily to rename your experimental branch.
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.
see this site.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With