7

On a GitHub repo, I'd like the master branch to actually be an alias to a x.y.z branch. As a consequence, all fetch/push from x.y.z and master would result to the exact same result. I do want to keep the master branch because people are used to it, but also want the x.y.z branch to not make master a special-case of a branch name (other branches are a.b.c, d.e.f...).

Is there a way to achieve that on GitHub? Or on a Git remote repository in general?

Mickael
  • 3,506
  • 1
  • 21
  • 33

1 Answers1

5

On GitHub side, you can change the default branch.
On a remote repo side, you can similarly change the default branch.

Setting a branch alias is not directly possible on GitHub side.
It is on a remote hosting git repo server you have access to:

git symbolic-ref refs/heads/master refs/heads/x.y.z

But the alias part would not propagate to a git cloned repo: while every new clone would checkout by default x.y.z, their user would have to setup the alias locally.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Ok, thanks. And what if I 'git clone --bare' the GitHub repo, run the 'git symbolic-ref' command you advised ans the use 'git pushh --mirror'? – Mickael Jun 10 '16 at 22:00
  • @Mickael you can try, but I believe the alias will not be pushed, only the resolved commit pointed by said alias. And the default branch reference will *not* be pushed either: that reference remains local to the repo, to be used when other are cloning it. – VonC Jun 10 '16 at 22:03
  • Ok, I tried and indeed, the symbolic-ref branch isn't interpreted as a symbolic-refs branch after a 'git push --mirror'. It's created as a regular branch. The limitation is both on the Git protocol that seems to ignore symbolic-refs and push symbolic branch as regular one, and on GitHub that doesn't provide support for "aliases". – Mickael Jun 11 '16 at 09:15
  • 2
    @Mickael I agree. Those symbolic-ref and aliases are for local use only. – VonC Jun 11 '16 at 10:33