From "Fix: crash when café name has "quotes"!" to a branch git accepts
Ticket titles are written for people, and people use punctuation. Paste one straight into git switch -c and git often refuses it. Take a real-looking bug: ticket PROJ-123, titled Fix: crash when café name has "quotes"!, on a bugfix branch. This page turns it into bugfix/PROJ-123-fix-crash-when-cafe-name-has-quotes. Here is what happens at each step, and which of git’s rules each step is there for.
First the type. bugfix is reduced to lower-case letters and digits and given a trailing slash. The slash is allowed in a branch name because git stores branches like files in folders; it is the only slash the page will produce. Next the ticket. PROJ-123 keeps its capitals, letters, digits and dash, but anything else is removed, so #42 would become 42. That matters because a branch name cannot contain some characters at all, and a few others, such as #, cause trouble in shells and URLs even where git allows them.
Then the description. The é in café is split into a plain e and an accent mark, and the mark is dropped, so café becomes cafe. Git would accept the é, but many tools, terminals and CI scripts handle non-ASCII names badly. The text is then lower-cased and cut wherever there is something that is not a letter or a digit. The colon after Fix, the two double quotes, the exclamation mark and every space become word breaks. What is left is seven words: fix, crash, when, cafe, name, has, quotes. Joined with dashes after the ticket, that is the name above, 51 characters long.
Each removed character was there for a reason. git check-ref-format, the command git uses to judge names, rejects spaces and the characters ~ ^ : ? * [ and backslash, because they have meanings in revision syntax and wildcards. It also rejects two dots in a row (used for ranges like main..feature), the pair @{ (used for reflog entries like main@{1}), a name ending in .lock (git’s own lock files) and a name ending in a slash. We ran the result through git check-ref-format --branch and it passed. The original title, with its space and colon, fails.
Length is the last step. The default limit is 60 characters, and the description is cut at a whole word to stay under it. A ticket called make the settings page remember the last tab the user opened across sessions becomes feature/PROJ-123-make-the-settings-page-remember-the-last, which is 57 characters; adding tab would have made 61. You keep the words that say what the branch is, and the ticket links to the rest.
The limits are simple to state. The page only keeps English letters and digits, so a description written in another script contributes nothing, and you should type a short English summary instead. It does not check whether the branch already exists in your repository; git will tell you that when you run the command. And it follows no single team’s convention, which is why the type, separator and case are yours to set.