My employer likes to use version numbers in their branch names. I dislike having to remember and verify whatever the current number is. Is there a way to "tag" or alias their branch, so I can use a branch name which does not change?
For example, they like to use:
So it changes every release. I don't have any influence and the rest of the herd like it this way, so there is no point in telling me not to do that.
It would be nice if I could pull and push to "release/env-app", or "foobar" for that matter.
I can't actually 'git tag' because that refers to a specific commit, whereas this is constantly changing. Unless it is possible to tag the HEAD commit of a branch?
I can't actually 'git tag' because that refers to a specific commit, whereas this is constantly changing. Unless it is possible to tag the HEAD commit of a branch?
If you were to tag the head of a branch, you would still tag a specific commit (the branch's tip). What you're looking for is some sort of "branch alias" instead.
To create an "alias" that always points to the tip of your release branch, you could use a symbolic reference (or symref). A symref is simply a pointer to another reference, and is implemented as a file with the name of its target. This would work exactly like the symbolic reference HEAD, where your custom symref would point to the given branch and, therefore, indirectly to its tip.
You can create a symref with the plumbing command git symbolic-ref
.
git symbolic-ref refs/heads/foobar refs/heads/release/env-app-44-0-2
Like so, you could use foobar
to perform any operation (checkout
, rebase
, etc.) as if you were actually working with the branch env-app-44-0-2
. Then, once the next release branch is ready, you can update the symref with the new branch.
git symbolic-ref refs/heads/foobar refs/heads/release/env-app-44-0-3