git更改默认分支(gitolite)

duc*_*cin 3 git rename gitolite git-branch

我有一个包含分支的存储库:master和devel.Master是默认的.我想将master重命名为prod并将其设为默认值(并将其推送到服务器).这该怎么做?

存储库以gitolite(如果重要)托管.

Von*_*onC 6

您需要访问服务器才能将HEAD的symbolic-ref更改为您在那里推送的分支(prod).

git-symbolic-ref HEAD refs/head/prod
Run Code Online (Sandbox Code Playgroud)

我暂时提出了一种方法,在" 如何更改Git远程HEAD以指向除"master"之外的其他内容时,从客户端那样做,但如果您可以直接登录服务器则更容易.

注意:使用最新的Gitolite V3,您实际上可以运行该命令(请参阅" 非核心命令 "):

/home/git/gitolite# gitolite symbolic-ref -h

Usage:    ssh git@host symbolic-ref <repo> <arguments to git-symbolic-ref>

allow 'git symbolic-ref' over a gitolite connection
Run Code Online (Sandbox Code Playgroud)

因此,通过ssh命令,您实际上可以更改由gitolite(V3)管理的远程存储库的HEAD.

ssh git@host symbolic-ref <repo> refs/head/prod
Run Code Online (Sandbox Code Playgroud)