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 <refname>
10       git check-ref-format --print <refname>
11       git check-ref-format --branch <branchname-shorthand>
12
13

DESCRIPTION

15       Checks if a given refname is acceptable, and exits with a non-zero
16       status if it is not.
17
18       A reference is used in git to specify branches and tags. A branch head
19       is stored under the $GIT_DIR/refs/heads directory, and a tag is stored
20       under the $GIT_DIR/refs/tags directory (or, if refs are packed by git
21       gc, as entries in the $GIT_DIR/packed-refs file). git imposes the
22       following rules on how references are named:
23
24        1. They can include slash / for hierarchical (directory) grouping, but
25           no slash-separated component can begin with a dot ..
26
27        2. They must contain at least one /. This enforces the presence of a
28           category like heads/, tags/ etc. but the actual names are not
29           restricted.
30
31        3. They cannot have two consecutive dots ..  anywhere.
32
33        4. They cannot have ASCII control characters (i.e. bytes whose values
34           are lower than \040, or \177 DEL), space, tilde ~, caret ^, colon
35           :, question-mark ?, asterisk *, or open bracket [ anywhere.
36
37        5. They cannot end with a slash / nor a dot ..
38
39        6. They cannot end with the sequence .lock.
40
41        7. They cannot contain a sequence @{.
42
43        8. They cannot contain a \.
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
47       is used unquoted (by mistake), and also avoids ambiguities in certain
48       reference name expressions (see gitrevisions(7)):
49
50        1. A double-dot ..  is often used as in ref1..ref2, and in some
51           contexts this notation means ^ref1 ref2 (i.e. not in ref1 and in
52           ref2).
53
54        2. A tilde ~ and caret ^ are used to introduce the postfix nth parent
55           and peel onion operation.
56
57        3. A colon : is used as in srcref:dstref to mean "use srcref’s value
58           and store it in dstref" in fetch and push operations. It may also
59           be used to select a specific object such as with git cat-file: "git
60           cat-file blob v1.3.3:refs.c".
61
62        4. at-open-brace @{ is used as a notation to access a reflog entry.
63
64       With the --print option, if refname is acceptable, it prints the
65       canonicalized name of a hypothetical reference with that name. That is,
66       it prints refname with any extra / characters removed.
67
68       With the --branch option, it expands the “previous branch syntax”
69       @{-n}. For example, @{-1} is a way to refer the last branch you were
70       on. This option should be used by porcelains to accept this syntax
71       anywhere a branch name is expected, so they can act as if you typed the
72       branch name.
73

EXAMPLES

75       ·   Print the name of the previous branch:
76
77               $ git check-ref-format --branch @{-1}
78
79
80       ·   Determine the reference name to use for a new branch:
81
82               $ ref=$(git check-ref-format --print "refs/heads/$newbranch") ||
83               die "we do not like '$newbranch' as a branch name."
84
85

GIT

87       Part of the git(1) suite
88
89
90
91Git 1.7.4.4                       04/11/2011              GIT-CHECK-REF-FOR(1)
Impressum