如何将我的git'master'分支重命名为'release'? [英] How do I rename my git 'master' branch to 'release'?

查看:938
本文介绍了如何将我的git'master'分支重命名为'release'?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们希望为我们的项目实施一项新政策,即主分支机构现在被称为发布分支机构,以确保分支机构应该如何使用。当然,我们也会开发和发布候选分支。



我明白我可以通过简单地使用以下命令来在本地重命名master分支:

  git branch -m master release 



<但是,这只是本地的。即使我将其推送到远程,HEAD仍然指向远程主分支。我希望彻底摆脱master分支,并在初始克隆时创建默认的本地分支,然后释放。



我该如何做到这一点?



编辑:看起来,由于原点位于有价值的服务器上,因此删除主分支时出现错误。我试图看看现在是否有可能改变这一点,以便默认分支是'释放'。

p> git checkout -b释放master#创建并切换到释放分支
git push -u原始释放#将释放分支推送到远程并跟踪它
git分支 - d主机#删除本地主机
git push - 删除原始主机#删除远程主机
git remote prune origin#删除远程跟踪分支


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?

EDIT: 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'.

解决方案

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

这篇关于如何将我的git'master'分支重命名为'release'?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆