Merge branch 'rc/maint-http-local-slot-fix' into rc/http-push
[git] / Documentation / git-check-ref-format.txt
1 git-check-ref-format(1)
2 =======================
3
4 NAME
5 ----
6 git-check-ref-format - Ensures that a reference name is well formed
7
8 SYNOPSIS
9 --------
10 [verse]
11 'git check-ref-format' <refname>
12 'git check-ref-format' [--branch] <branchname-shorthand>
13
14 DESCRIPTION
15 -----------
16 Checks if a given 'refname' is acceptable, and exits with a non-zero
17 status if it is not.
18
19 A reference is used in git to specify branches and tags.  A
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:
23
24 . They can include slash `/` for hierarchical (directory)
25   grouping, but no slash-separated component can begin with a
26   dot `.`.
27
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
32 . They cannot have two consecutive dots `..` anywhere.
33
34 . They cannot have ASCII control characters (i.e. bytes whose
35   values are lower than \040, or \177 `DEL`), space, tilde `~`,
36   caret `{caret}`, colon `:`, question-mark `?`, asterisk `*`,
37   or open bracket `[` anywhere.
38
39 . They cannot end with a slash `/` nor a dot `.`.
40
41 . They cannot end with the sequence `.lock`.
42
43 . They cannot contain a sequence `@{`.
44
45 These rules make it easy for shell script based tools to parse
46 reference names, pathname expansion by the shell when a reference name is used
47 unquoted (by mistake), and also avoids ambiguities in certain
48 reference name expressions (see linkgit:git-rev-parse[1]):
49
50 . A double-dot `..` is often used as in `ref1..ref2`, and in some
51   contexts this notation means `{caret}ref1 ref2` (i.e. not in
52   `ref1` and in `ref2`).
53
54 . A tilde `~` and caret `{caret}` are used to introduce the postfix
55   'nth parent' and 'peel onion' operation.
56
57 . A colon `:` is used as in `srcref:dstref` to mean "use srcref\'s
58   value and store it in dstref" in fetch and push operations.
59   It may also be used to select a specific object such as with
60   'git-cat-file': "git cat-file blob v1.3.3:refs.c".
61
62 . at-open-brace `@{` is used as a notation to access a reflog entry.
63
64 With the `--branch` option, it expands a branch name shorthand and
65 prints the name of the branch the shorthand refers to.
66
67 EXAMPLE
68 -------
69
70 git check-ref-format --branch @{-1}::
71
72 Print the name of the previous branch.
73
74
75 GIT
76 ---
77 Part of the linkgit:git[1] suite