git checkout -b release master # Create and switch to the release branch
git push -u origin release # Push the release branch to the remote and track it
git branch -d master # Delete local master
git push --delete origin master # Delete remote master
git remote prune origin # Delete the remote tracking branch
Please note, if you are using GitHub you will need to first change your "default" branch on GitHub after step 3:
In your repository on github.com go Settings → Branches → Default Branch. Change it to release and then do the rest of the steps.
git checkout master
git branch release
git checkout release
git push origin release
git push origin :master
git branch -d master
Note: This answer is intended for self-hosted Git servers where you have command line access.
Since trying to delete the remote master
from a client indeed is not allowed and I do assume forbidding denyDeleteCurrent
makes sense, I would not like to change that setting.
However, I found that the easiest way to rename your master iff you have command line access to the remote server is to run the rename command directly on remote.
This worked for me:
git branch -m master release
Now the remote repository uses release
as its default branch and any git clone
on that repository from any client will check out the release branch by default.
It is very helpful also after setting up a bare repository to configure it to your needs.
As previously stated by others, the issue here is Gitorious, which doesn't let you delete the HEAD branch per default. You have two options get around this problem. One is to log into the Gitorious server (with ssh), find the Git repository on the file server and add:
[receive]
denyDeleteCurrent = warn
to the configuration.
An easier option is just to change the default branch. Go to you repository in the Gitorious web interface, press "Edit repository", and set "Head Change the symbolic ref the HEAD in the Git repository points to:". After you've done this you can delete the master branch.
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