Is there a git max tag name length?

3.5k Views Asked by At

I'm curious if there are any limits on the length of a git tag name. If not within the official git documentation, then what about some of the more popular platforms such as github, bitbucket, gitlab, etc.?

The docs I've seen do not list a length limitation on the tag name. But there has to be some kind of a limit since nothing is unlimited, eventually something will fail when you reach a "limit". Here are two primary docs that relate to tagging and specifically the tag name.

https://git-scm.com/docs/git-tag https://git-scm.com/docs/git-check-ref-format

The primary reason why I'm asking this question is that a SVN repo I've been using for the last 8+ years is trying to be moved to git (a bitbucket repo), and the feedback I'm getting is that "long" tag names are causing a mess of troubles and is preventing the migration. The longest tag name I can locate in the repo is less than 60 characters in length with less than 100 tags.

Are there any limitations in tag name length?

1

There are 1 best solutions below

1
On BEST ANSWER

There are several, but they vary:

  • Because individual name components are sometimes stored in file system names, a tag name of the form comp/on/ent has a limit on each of the pieces: comp, on, and ent. The actual limit on a Linux system depends on the underlying file system, and is typically 255 characters. Other file systems may have shorter limits (some might allow longer names but 255 is usually plenty).

  • Because the entire name is sometimes stored as a file-system name, the full name, refs/tags/comp/on/ent may have a system-imposed limit. This could be 1024 characters (old Unix systems), 4096 characters (some current Unix/Linux systems), or some other value—typically much smaller on a Windows system. See also Where is PATH_MAX defined in Linux?

  • The PATH_MAX limit might be relative (.git/refs/tags/... where .git/ takes five more bytes off the maximum) or absolute (/path/to/repo/.git/refs/tags/... where /path/to/repo/.git/ takes more than five more bytes off the limit).

Internally within Git, there used to be various buffers of size 1024 or PATH_MAX, but these should all be cleaned up in a modern Git, so that you should generally only run into the system-wide limits, such as a Windows 260-byte PATH_MAX.

Note, however, that tags are presented to humans. Humans tend to be quite a bit more limited here. I'd recommend keeping yourself to maybe 20 to 100 characters or so, depending on how systematic your tags are.