1

In git, is it possible to create a pointer to a tag that can be used like a tag itself, but be moved to point to another tag at a later date?


Usage: for each release that gets deployed to production, we create a tag like: release-some-identifier , and want a pointer simply called release that refers to the last release (will always refer to the last release),

and then on the next release, move it to point to the latest tag that was created with a new identifier.

user10664542
  • 1,106
  • 1
  • 23
  • 43
  • 1
    Any "pointer", actually a ref, can point to any commit. You can use a tag (`git tag release `) and then move it by tagging another commit (`git tag -f release `). Tags are not supposed to be committed to therefore be mutable though: you can use a branch too that is supposed to be mutable and also "accepts commit" (so you have to reject commits to the "release" branch via hooks or at least just by convention). – terrorrussia-keeps-killing Dec 29 '20 at 16:59
  • 1
    If neither tag, nor branch are fine for you, you can try using custom references. Say, creating a release reference might be like this: `git update-ref refs/release ` (inspect the list of all refs by `git for-each-ref` or `git show-ref`), but as far as I know, remote git instances reject references that are not prefixed with any of `refs/heads`, `refs/tags`, or `refs/notes` (attempting to push to such a remote will be rejected with a "funny refname" error). – terrorrussia-keeps-killing Dec 29 '20 at 17:17
  • Note that by convention, a *moving pointer to a commit* is called a "branch name", and a *non-moving pointer to a commit* is called a "tag name". That's it—that's what branch and tag names are about. :-) – torek Dec 29 '20 at 21:04
  • And, just for completeness, a pointer to a branch *name* is called *symref* or *symbolic reference*. – j6t Dec 29 '20 at 21:10
  • j6t: oh god - unbelievable. – user10664542 Jan 04 '21 at 20:48

0 Answers0