1GIT-NAME-REV(1) Git Manual GIT-NAME-REV(1)
2
3
4
6 git-name-rev - Find symbolic names for given revs
7
9 git name-rev [--tags] [--refs=<pattern>]
10 ( --all | --annotate-stdin | <commit-ish>... )
11
13 Finds symbolic names suitable for human digestion for revisions given
14 in any format parsable by git rev-parse.
15
17 --tags
18 Do not use branch names, but only tags to name the commits
19
20 --refs=<pattern>
21 Only use refs whose names match a given shell pattern. The pattern
22 can be a branch name, a tag name, or a fully qualified ref name. If
23 given multiple times, use refs whose names match any of the given
24 shell patterns. Use --no-refs to clear any previous ref patterns
25 given.
26
27 --exclude=<pattern>
28 Do not use any ref whose name matches a given shell pattern. The
29 pattern can be one of branch name, tag name or fully qualified ref
30 name. If given multiple times, a ref will be excluded when it
31 matches any of the given patterns. When used together with --refs,
32 a ref will be used as a match only when it matches at least one
33 --refs pattern and does not match any --exclude patterns. Use
34 --no-exclude to clear the list of exclude patterns.
35
36 --all
37 List all commits reachable from all refs
38
39 --annotate-stdin
40 Transform stdin by substituting all the 40-character SHA-1 hexes
41 (say $hex) with "$hex ($rev_name)". When used with --name-only,
42 substitute with "$rev_name", omitting $hex altogether. This option
43 was called --stdin in older versions of Git.
44
45 For example:
46
47 $ cat sample.txt
48
49 An abbreviated revision 2ae0a9cb82 will not be substituted.
50 The full name after substitution is 2ae0a9cb8298185a94e5998086f380a355dd8907,
51 while its tree object is 70d105cc79e63b81cfdcb08a15297c23e60b07ad
52
53 $ git name-rev --annotate-stdin <sample.txt
54
55 An abbreviated revision 2ae0a9cb82 will not be substituted.
56 The full name after substitution is 2ae0a9cb8298185a94e5998086f380a355dd8907 (master),
57 while its tree object is 70d105cc79e63b81cfdcb08a15297c23e60b07ad
58
59 $ git name-rev --name-only --annotate-stdin <sample.txt
60
61 An abbreviated revision 2ae0a9cb82 will not be substituted.
62 The full name after substitution is master,
63 while its tree object is 70d105cc79e63b81cfdcb08a15297c23e60b07ad
64
65 --name-only
66 Instead of printing both the SHA-1 and the name, print only the
67 name. If given with --tags the usual tag prefix of "tags/" is also
68 omitted from the name, matching the output of git-describe more
69 closely.
70
71 --no-undefined
72 Die with error code != 0 when a reference is undefined, instead of
73 printing undefined.
74
75 --always
76 Show uniquely abbreviated commit object as fallback.
77
79 Given a commit, find out where it is relative to the local refs. Say
80 somebody wrote you about that fantastic commit
81 33db5f4d9027a10e477ccf054b2c1ab94f74c85a. Of course, you look into the
82 commit, but that only tells you what happened, but not the context.
83
84 Enter git name-rev:
85
86 % git name-rev 33db5f4d9027a10e477ccf054b2c1ab94f74c85a
87 33db5f4d9027a10e477ccf054b2c1ab94f74c85a tags/v0.99~940
88
89 Now you are wiser, because you know that it happened 940 revisions
90 before v0.99.
91
92 Another nice thing you can do is:
93
94 % git log | git name-rev --annotate-stdin
95
97 Part of the git(1) suite
98
99
100
101Git 2.43.0 11/20/2023 GIT-NAME-REV(1)