]>
Commit | Line | Data |
---|---|---|
622ef9df JH |
1 | git-check-ref-format(1) |
2 | ======================= | |
3 | ||
4 | NAME | |
5 | ---- | |
cd747dc6 | 6 | git-check-ref-format - Ensures that a reference 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 | ----------- | |
cd747dc6 DM |
16 | Checks if a given 'refname' is acceptable, and exits with a non-zero |
17 | status if it is not. | |
622ef9df JH |
18 | |
19 | A reference is used in git to specify branches and tags. A | |
cd747dc6 DM |
20 | branch head is stored under the `$GIT_DIR/refs/heads` directory, and |
21 | a tag is stored under the `$GIT_DIR/refs/tags` directory. git | |
22 | imposes the following rules on how references are named: | |
622ef9df | 23 | |
cd747dc6 | 24 | . They can include slash `/` for hierarchical (directory) |
37425065 | 25 | grouping, but no slash-separated component can begin with a |
cd747dc6 | 26 | dot `.`. |
622ef9df | 27 | |
1a287259 MG |
28 | . They must contain at least one `/`. This enforces the presence of a |
29 | category like `heads/`, `tags/` etc. but the actual names are not | |
30 | restricted. | |
31 | ||
cd747dc6 | 32 | . They cannot have two consecutive dots `..` anywhere. |
622ef9df | 33 | |
cd747dc6 | 34 | . They cannot have ASCII control characters (i.e. bytes whose |
622ef9df | 35 | values are lower than \040, or \177 `DEL`), space, tilde `~`, |
68283999 | 36 | caret `{caret}`, colon `:`, question-mark `?`, asterisk `*`, |
cd747dc6 | 37 | or open bracket `[` anywhere. |
622ef9df | 38 | |
cbdffe40 JH |
39 | . They cannot end with a slash `/` nor a dot `.`. |
40 | ||
3e262b95 SP |
41 | . They cannot end with the sequence `.lock`. |
42 | ||
cbdffe40 | 43 | . They cannot contain a sequence `@{`. |
622ef9df | 44 | |
a4c2e699 RR |
45 | - They cannot contain a `\\`. |
46 | ||
cd747dc6 DM |
47 | These rules make it easy for shell script based tools to parse |
48 | reference names, pathname expansion by the shell when a reference name is used | |
68283999 | 49 | unquoted (by mistake), and also avoids ambiguities in certain |
cd747dc6 | 50 | reference name expressions (see linkgit:git-rev-parse[1]): |
622ef9df | 51 | |
cd747dc6 DM |
52 | . A double-dot `..` is often used as in `ref1..ref2`, and in some |
53 | contexts this notation means `{caret}ref1 ref2` (i.e. not in | |
54 | `ref1` and in `ref2`). | |
622ef9df | 55 | |
cd747dc6 | 56 | . A tilde `~` and caret `{caret}` are used to introduce the postfix |
622ef9df JH |
57 | 'nth parent' and 'peel onion' operation. |
58 | ||
cd747dc6 | 59 | . A colon `:` is used as in `srcref:dstref` to mean "use srcref\'s |
622ef9df | 60 | value and store it in dstref" in fetch and push operations. |
87a56cd3 | 61 | It may also be used to select a specific object such as with |
ba020ef5 | 62 | 'git-cat-file': "git cat-file blob v1.3.3:refs.c". |
622ef9df | 63 | |
cbdffe40 JH |
64 | . at-open-brace `@{` is used as a notation to access a reflog entry. |
65 | ||
a31dca03 JH |
66 | With the `--branch` option, it expands a branch name shorthand and |
67 | prints the name of the branch the shorthand refers to. | |
68 | ||
69 | EXAMPLE | |
70 | ------- | |
71 | ||
72 | git check-ref-format --branch @{-1}:: | |
73 | ||
74 | Print the name of the previous branch. | |
75 | ||
622ef9df JH |
76 | |
77 | GIT | |
78 | --- | |
9e1f0a85 | 79 | Part of the linkgit:git[1] suite |