]>
Commit | Line | Data |
---|---|---|
622ef9df JH |
1 | git-check-ref-format(1) |
2 | ======================= | |
3 | ||
4 | NAME | |
5 | ---- | |
7bd7f280 | 6 | git-check-ref-format - Make sure ref name is well formed |
622ef9df JH |
7 | |
8 | SYNOPSIS | |
9 | -------- | |
a31dca03 | 10 | [verse] |
b1889c36 | 11 | 'git check-ref-format' <refname> |
a31dca03 | 12 | 'git check-ref-format' [--branch] <branchname-shorthand> |
622ef9df JH |
13 | |
14 | DESCRIPTION | |
15 | ----------- | |
16 | Checks if a given 'refname' is acceptable, and exits non-zero if | |
17 | it is not. | |
18 | ||
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: | |
23 | ||
37425065 FD |
24 | . It can include slash `/` for hierarchical (directory) |
25 | grouping, but no slash-separated component can begin with a | |
26 | dot `.`; | |
622ef9df JH |
27 | |
28 | . It cannot have two consecutive dots `..` anywhere; | |
29 | ||
30 | . It cannot have ASCII control character (i.e. bytes whose | |
31 | values are lower than \040, or \177 `DEL`), space, tilde `~`, | |
68283999 JH |
32 | caret `{caret}`, colon `:`, question-mark `?`, asterisk `*`, |
33 | or open bracket `[` anywhere; | |
622ef9df JH |
34 | |
35 | . It cannot end with a slash `/`. | |
36 | ||
37 | These rules makes it easy for shell script based tools to parse | |
68283999 JH |
38 | refnames, pathname expansion by the shell when a refname is used |
39 | unquoted (by mistake), and also avoids ambiguities in certain | |
5162e697 | 40 | refname expressions (see linkgit:git-rev-parse[1]). Namely: |
622ef9df JH |
41 | |
42 | . double-dot `..` are often used as in `ref1..ref2`, and in some | |
43 | context this notation means `{caret}ref1 ref2` (i.e. not in | |
44 | ref1 and in ref2). | |
45 | ||
46 | . tilde `~` and caret `{caret}` are used to introduce postfix | |
47 | 'nth parent' and 'peel onion' operation. | |
48 | ||
49 | . colon `:` is used as in `srcref:dstref` to mean "use srcref\'s | |
50 | value and store it in dstref" in fetch and push operations. | |
87a56cd3 | 51 | It may also be used to select a specific object such as with |
ba020ef5 | 52 | 'git-cat-file': "git cat-file blob v1.3.3:refs.c". |
622ef9df | 53 | |
a31dca03 JH |
54 | With the `--branch` option, it expands a branch name shorthand and |
55 | prints the name of the branch the shorthand refers to. | |
56 | ||
57 | EXAMPLE | |
58 | ------- | |
59 | ||
60 | git check-ref-format --branch @{-1}:: | |
61 | ||
62 | Print the name of the previous branch. | |
63 | ||
622ef9df JH |
64 | |
65 | GIT | |
66 | --- | |
9e1f0a85 | 67 | Part of the linkgit:git[1] suite |