DaikonBoy
DaikonBoy

Reputation: 158

How to create a GIT branch that point to another branch instead of a commit

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.

Upvotes: 4

Views: 409

Answers (2)

John Jesus
John Jesus

Reputation: 2404

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

Upvotes: 3

jthill
jthill

Reputation: 60555

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

Upvotes: 4

Related Questions