How do I rename my Git 'master' branch to 'release'?

Kyle Hayes

We would like to enforce a new policy for our projects that the master branch now be called the release branch to ensure it is more clear as to how the branch should be used. Naturally, we will have develop and release candidate branches as well.

I understand I can rename the master branch locally by simply using the following:

git branch -m master release

However, that is only locally. Even if I push this up to the remote, the HEAD still points to the remote master branch. I want to get rid of the master branch completely and make the default local branch upon initial clone, be release.

How can I achieve this?

It seems that since the origin is on a Gitorious server, I get errors deleting the master branch. I'm trying to see now if it is possible to change this so that the default branch is 'release'.

Adam Dymitruk
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 SettingsBranchesDefault Branch. Change it to release and then do the rest of the steps.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How do I rename a local Git branch?

In git, how do I verify that bug fixes are in both the Release branch and in master

Should I replace my master branch with my release branch or merge my release branch into my master branch?

Git: How do I merge the remote branch of another developer's with my master branch?

How do I push a local Git branch to master branch in the remote?

How do I create release branch from master, excluding particular branch which is already merge in master

How do I push up my changes to a master git organization from a forked copy dev branch?

How can I keep my branch up to date with master with git?

GIT: How can I prevent foxtrot merges in my 'master' branch?

With Git, after my code commits are merged to the master branch, do I delete my remote branch, clone master again and checkout the next branch?

How do I rename both a Git local and remote branch name?

How do I create a master branch in a bare Git repository?

How do I safely merge a Git branch into master?

How do I add a git submodule that has no master branch?

How do Git branches work? Can I remove the master branch?

How do I get a git conflict between a fork and the master branch

How do I delete a git master branch on my terminal when there it is attache to my home folder and the repository on GitHub was deleted?

Git - What happens to my local master branch after a pull request? How do I manage multiple in progress branches?

How can I rename a local Git branch?

How to create a git release branch from a directory that is not checked in remote master

How do I change a feature branch of a local git repo without changing the master branch?

How do I reset the git master branch to the upstream branch in a forked repository?

How do I update my feature branch commits to be on top of the updated master branch?

How do I rename branch on the GitHub website?

How do I know the git branch my rails server is running on?

How do I create a deploy git branch for my Yeoman project?

Git: How do I retrieve a branch that is no longer on my local machine?

Can I use git push origin master:myBranch to push code I modified in master branch to my branch?

Git: How can I merge local branch into remote master branch

TOP Ranking

HotTag

Archive