gitk: Second try to work around the command line limit on Windows
[git/dscho.git] / Documentation / git-check-ref-format.txt
blob379eee6734323ee566480d5f9159dd28ed27ecd2
1 git-check-ref-format(1)
2 =======================
4 NAME
5 ----
6 git-check-ref-format - Ensures that a reference name is well formed
8 SYNOPSIS
9 --------
10 [verse]
11 'git check-ref-format' <refname>
12 'git check-ref-format' --print <refname>
13 'git check-ref-format' --branch <branchname-shorthand>
15 DESCRIPTION
16 -----------
17 Checks if a given 'refname' is acceptable, and exits with a non-zero
18 status if it is not.
20 A reference is used in git to specify branches and tags.  A
21 branch head is stored under the `$GIT_DIR/refs/heads` directory, and
22 a tag is stored under the `$GIT_DIR/refs/tags` directory (or, if refs
23 are packed by `git gc`, as entries in the `$GIT_DIR/packed-refs` file).
24 git imposes the following rules on how references are named:
26 . They can include slash `/` for hierarchical (directory)
27   grouping, but no slash-separated component can begin with a
28   dot `.`.
30 . They must contain at least one `/`. This enforces the presence of a
31   category like `heads/`, `tags/` etc. but the actual names are not
32   restricted.
34 . They cannot have two consecutive dots `..` anywhere.
36 . They cannot have ASCII control characters (i.e. bytes whose
37   values are lower than \040, or \177 `DEL`), space, tilde `~`,
38   caret `{caret}`, colon `:`, question-mark `?`, asterisk `*`,
39   or open bracket `[` anywhere.
41 . They cannot end with a slash `/` nor a dot `.`.
43 . They cannot end with the sequence `.lock`.
45 . They cannot contain a sequence `@{`.
47 . They cannot contain a `\`.
49 These rules make it easy for shell script based tools to parse
50 reference names, pathname expansion by the shell when a reference name is used
51 unquoted (by mistake), and also avoids ambiguities in certain
52 reference name expressions (see linkgit:git-rev-parse[1]):
54 . A double-dot `..` is often used as in `ref1..ref2`, and in some
55   contexts this notation means `{caret}ref1 ref2` (i.e. not in
56   `ref1` and in `ref2`).
58 . A tilde `~` and caret `{caret}` are used to introduce the postfix
59   'nth parent' and 'peel onion' operation.
61 . A colon `:` is used as in `srcref:dstref` to mean "use srcref\'s
62   value and store it in dstref" in fetch and push operations.
63   It may also be used to select a specific object such as with
64   'git cat-file': "git cat-file blob v1.3.3:refs.c".
66 . at-open-brace `@{` is used as a notation to access a reflog entry.
68 With the `--print` option, if 'refname' is acceptable, it prints the
69 canonicalized name of a hypothetical reference with that name.  That is,
70 it prints 'refname' with any extra `/` characters removed.
72 With the `--branch` option, it expands the ``previous branch syntax''
73 `@{-n}`.  For example, `@{-1}` is a way to refer the last branch you
74 were on.  This option should be used by porcelains to accept this
75 syntax anywhere a branch name is expected, so they can act as if you
76 typed the branch name.
78 EXAMPLES
79 --------
81 * Print the name of the previous branch:
83 ------------
84 $ git check-ref-format --branch @{-1}
85 ------------
87 * Determine the reference name to use for a new branch:
89 ------------
90 $ ref=$(git check-ref-format --print "refs/heads/$newbranch") ||
91 die "we do not like '$newbranch' as a branch name."
92 ------------
94 GIT
95 ---
96 Part of the linkgit:git[1] suite