git change default branch (gitolite)

2019-02-19 01:48发布

I've got a repository with branches: master and devel. Master is the default one. I want to rename master into prod and make it default (and push it to the server). How to do this?

Repository is hosted in gitolite (if it matters).

2条回答
干净又极端
2楼-- · 2019-02-19 02:06

You need to have access to the server in order to change the symbolic-ref of HEAD to the branch you have pushed there (prod).

git-symbolic-ref HEAD refs/head/prod

I tentatively proposed a way to do that from a client at the end of "How do I change a Git remote HEAD to point to something besides “master”", but it is easier if you can log on the server directly.

Note: with the latest Gitolite V3, you actually can run that command (see "non-core commands"):

/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

So, through an ssh command, you actually can change HEAD for remote repos managed by gitolite (V3).

ssh git@host symbolic-ref <repo> refs/head/prod
查看更多
爷的心禁止访问
3楼-- · 2019-02-19 02:13

I had to use (Gitolite 3.5.3):

ssh git@host symbolic-ref <repo> HEAD refs/heads/prod
查看更多
登录 后发表回答