4

Knowing that a branch is a pointer to the last commit. By example, the master branch is linked to the commit C1.

I want to know if it's possible to link a branch to another branch instead of a commit, which would make it a pointer of pointer (for those accustomed in C).

By example, I would like the master branch point to a release branch (by example 1.1). And if by any chance, a commit would happen in the branch 1.1, the master HEAD would follow the 1.1 HEAD.

DaikonBoy
  • 158
  • 6
  • Are you trying to solve the organizational issue with technical tools? What is the *real* task behind this "solution"? – zerkms Jun 09 '14 at 20:38
  • I don't think this is possible. It defeats the purpose of having branches in the first place. If you want to keep a branch up to date with another simply fetch and merge. Perhaps you can add a git hook that will run every time you commit on a branch and the git hook can do a pull for you from that other branch that you want to keep up to date with. – Chris Bier Jun 09 '14 at 20:40
  • 2
    Any reference can be symbolic. The `HEAD` reference is usually symbolic, but you can create a symbolic ref in the branch name-space by using a name that starts with `refs/heads/`, e.g., `git symbolic-ref refs/heads/INDIR refs/heads/master`. I have to ask the same question as @zerkms though. – torek Jun 09 '14 at 20:42
  • @torek I didn't see this before answering, why not make it an answer? – jthill Jun 09 '14 at 22:09
  • @jthill: it's not really a true branch. It works for some (many?) purposes but not all. So I'm not sure it's a *good* answer. :-) – torek Jun 09 '14 at 22:11
  • @(all here) - if you're publishing a stable/testing/experimental branches, and there aren't any even alpha-quality experiments going on, just set experimental to track testing until it's time. – jthill Jun 09 '14 at 22:11

2 Answers2

4

Yes, you can make branch aliases or aliases to any ref. Say:

git symbolic-ref refs/heads/trackmaster refs/heads/realmaster

and you no longer have to manually catch up (possibly temporarily-)joined LOD's

jthill
  • 55,082
  • 5
  • 77
  • 137
3

My apologies if this post ought rather to be a comment instead of an answer.

Git does not support aliases for branches.

Some good discussion on this subject in the answers to this StackOverflow question:

git - branch alias?

CORRECTION:

Actually, it looks like symbolic-ref is the way to alias a branch. There's a feature request on the Git mailing list with more info.

http://www.mail-archive.com/git%40vger.kernel.org/msg49171.html

Community
  • 1
  • 1
John Jesus
  • 2,284
  • 16
  • 18