1GIT-CHECK-REF-FOR(1)              Git Manual              GIT-CHECK-REF-FOR(1)
2
3
4

NAME

6       git-check-ref-format - Ensures that a reference name is well formed
7

SYNOPSIS

9       git check-ref-format [--normalize]
10              [--[no-]allow-onelevel] [--refspec-pattern]
11              <refname>
12       git check-ref-format --branch <branchname-shorthand>
13
14

DESCRIPTION

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 branch head
20       is stored in the refs/heads hierarchy, while a tag is stored in the
21       refs/tags hierarchy of the ref namespace (typically in
22       $GIT_DIR/refs/heads and $GIT_DIR/refs/tags directories or, as entries
23       in file $GIT_DIR/packed-refs if refs are packed by git gc).
24
25       Git imposes the following rules on how references are named:
26
27        1. They can include slash / for hierarchical (directory) grouping, but
28           no slash-separated component can begin with a dot .  or end with
29           the sequence .lock.
30
31        2. They must contain at least one /. This enforces the presence of a
32           category like heads/, tags/ etc. but the actual names are not
33           restricted. If the --allow-onelevel option is used, this rule is
34           waived.
35
36        3. They cannot have two consecutive dots ..  anywhere.
37
38        4. They cannot have ASCII control characters (i.e. bytes whose values
39           are lower than \040, or \177 DEL), space, tilde ~, caret ^, or
40           colon : anywhere.
41
42        5. They cannot have question-mark ?, asterisk *, or open bracket [
43           anywhere. See the --refspec-pattern option below for an exception
44           to this rule.
45
46        6. They cannot begin or end with a slash / or contain multiple
47           consecutive slashes (see the --normalize option below for an
48           exception to this rule)
49
50        7. They cannot end with a dot ..
51
52        8. They cannot contain a sequence @{.
53
54        9. They cannot contain a \.
55
56       These rules make it easy for shell script based tools to parse
57       reference names, pathname expansion by the shell when a reference name
58       is used unquoted (by mistake), and also avoids ambiguities in certain
59       reference name expressions (see gitrevisions(7)):
60
61        1. A double-dot ..  is often used as in ref1..ref2, and in some
62           contexts this notation means ^ref1 ref2 (i.e. not in ref1 and in
63           ref2).
64
65        2. A tilde ~ and caret ^ are used to introduce the postfix nth parent
66           and peel onion operation.
67
68        3. A colon : is used as in srcref:dstref to mean "use srcref’s value
69           and store it in dstref" in fetch and push operations. It may also
70           be used to select a specific object such as with git cat-file: "git
71           cat-file blob v1.3.3:refs.c".
72
73        4. at-open-brace @{ is used as a notation to access a reflog entry.
74
75       With the --branch option, it expands the “previous branch syntax”
76       @{-n}. For example, @{-1} is a way to refer the last branch you were
77       on. This option should be used by porcelains to accept this syntax
78       anywhere a branch name is expected, so they can act as if you typed the
79       branch name.
80

OPTIONS

82       --[no-]allow-onelevel
83           Controls whether one-level refnames are accepted (i.e., refnames
84           that do not contain multiple /-separated components). The default
85           is --no-allow-onelevel.
86
87       --refspec-pattern
88           Interpret <refname> as a reference name pattern for a refspec (as
89           used with remote repositories). If this option is enabled,
90           <refname> is allowed to contain a single * in place of a one full
91           pathname component (e.g., foo/*/bar but not foo/bar*).
92
93       --normalize
94           Normalize refname by removing any leading slash (/) characters and
95           collapsing runs of adjacent slashes between name components into a
96           single slash. Iff the normalized refname is valid then print it to
97           standard output and exit with a status of 0. (--print is a
98           deprecated way to spell --normalize.)
99

EXAMPLES

101       ·   Print the name of the previous branch:
102
103               $ git check-ref-format --branch @{-1}
104
105
106       ·   Determine the reference name to use for a new branch:
107
108               $ ref=$(git check-ref-format --normalize "refs/heads/$newbranch") ||
109               die "we do not like '$newbranch' as a branch name."
110
111

GIT

113       Part of the git(1) suite
114
115
116
117Git 1.8.3.1                       11/19/2018              GIT-CHECK-REF-FOR(1)
Impressum