1 git-check-ref-format(1)
2 =======================
6 git-check-ref-format - Make sure ref name is well formed
11 'git check-ref-format' <refname>
12 'git check-ref-format' [--branch] <branchname-shorthand>
16 Checks if a given 'refname' is acceptable, and exits non-zero if
19 A reference is used in git to specify branches and tags. A
20 branch head is stored under `$GIT_DIR/refs/heads` directory, and
21 a tag is stored under `$GIT_DIR/refs/tags` directory. git
22 imposes the following rules on how refs are named:
24 . It can include slash `/` for hierarchical (directory)
25 grouping, but no slash-separated component can begin with a
28 . It cannot have two consecutive dots `..` anywhere;
30 . It cannot have ASCII control character (i.e. bytes whose
31 values are lower than \040, or \177 `DEL`), space, tilde `~`,
32 caret `{caret}`, colon `:`, question-mark `?`, asterisk `*`,
33 or open bracket `[` anywhere;
35 . They cannot end with a slash `/` nor a dot `.`.
37 . They cannot end with the sequence `.lock`.
39 . They cannot contain a sequence `@{`.
41 These rules makes it easy for shell script based tools to parse
42 refnames, pathname expansion by the shell when a refname is used
43 unquoted (by mistake), and also avoids ambiguities in certain
44 refname expressions (see linkgit:git-rev-parse[1]). Namely:
46 . double-dot `..` are often used as in `ref1..ref2`, and in some
47 context this notation means `{caret}ref1 ref2` (i.e. not in
50 . tilde `~` and caret `{caret}` are used to introduce postfix
51 'nth parent' and 'peel onion' operation.
53 . colon `:` is used as in `srcref:dstref` to mean "use srcref\'s
54 value and store it in dstref" in fetch and push operations.
55 It may also be used to select a specific object such as with
56 'git-cat-file': "git cat-file blob v1.3.3:refs.c".
58 . at-open-brace `@{` is used as a notation to access a reflog entry.
60 With the `--branch` option, it expands a branch name shorthand and
61 prints the name of the branch the shorthand refers to.
66 git check-ref-format --branch @{-1}::
68 Print the name of the previous branch.
73 Part of the linkgit:git[1] suite