]>
Commit | Line | Data |
---|---|---|
65d9fb48 JS |
1 | git-notes(1) |
2 | ============ | |
3 | ||
4 | NAME | |
5 | ---- | |
7d541174 | 6 | git-notes - Add/inspect object notes |
65d9fb48 JS |
7 | |
8 | SYNOPSIS | |
9 | -------- | |
10 | [verse] | |
e397421a | 11 | 'git notes' [list [<object>]] |
0691cff7 | 12 | 'git notes' add [-f] [-F <file> | -m <msg> | (-c | -C) <object>] [<object>] |
160baa0d | 13 | 'git notes' copy [-f] ( --stdin | <from-object> <to-object> ) |
0691cff7 | 14 | 'git notes' append [-F <file> | -m <msg> | (-c | -C) <object>] [<object>] |
aaec9bcf | 15 | 'git notes' edit [<object>] |
e397421a JH |
16 | 'git notes' show [<object>] |
17 | 'git notes' remove [<object>] | |
18 | 'git notes' prune | |
19 | ||
65d9fb48 JS |
20 | |
21 | DESCRIPTION | |
22 | ----------- | |
7d541174 JH |
23 | This command allows you to add/remove notes to/from objects, without |
24 | changing the objects themselves. | |
65d9fb48 | 25 | |
00979710 JN |
26 | By default, notes are saved to and read from `refs/notes/commits`, but |
27 | this default can be overridden. See the OPTIONS, CONFIGURATION, and | |
28 | ENVIRONMENT sections below. If this ref does not exist, it will be | |
29 | quietly created when it is first needed to store a note. | |
30 | ||
7d541174 JH |
31 | A typical use of notes is to extend a commit message without having |
32 | to change the commit itself. Such commit notes can be shown by `git log` | |
33 | along with the original commit message. To discern these notes from the | |
34 | message stored in the commit object, the notes are indented like the | |
894a9d33 | 35 | message, after an unindented line saying "Notes (<refname>):" (or |
9eb3f816 | 36 | "Notes:" for `refs/notes/commits`). |
7d541174 | 37 | |
66c4c32d JN |
38 | To change which notes are shown by 'git log', see the |
39 | "notes.displayRef" configuration in linkgit:git-log[1]. | |
65d9fb48 | 40 | |
6956f858 TR |
41 | See the description of "notes.rewrite.<command>" in |
42 | linkgit:git-config[1] for a way of carrying your notes across commands | |
43 | that rewrite commits. | |
65d9fb48 JS |
44 | |
45 | ||
46 | SUBCOMMANDS | |
47 | ----------- | |
48 | ||
e397421a JH |
49 | list:: |
50 | List the notes object for a given object. If no object is | |
51 | given, show a list of all note objects and the objects they | |
52 | annotate (in the format "<note object> <annotated object>"). | |
53 | This is the default subcommand if no subcommand is given. | |
54 | ||
7aa4754e JH |
55 | add:: |
56 | Add notes for a given object (defaults to HEAD). Abort if the | |
48716a23 | 57 | object already has notes (use `-f` to overwrite an |
7aa4754e JH |
58 | existing note). |
59 | ||
e73bbd96 JH |
60 | copy:: |
61 | Copy the notes for the first object onto the second object. | |
62 | Abort if the second object already has notes, or if the first | |
48716a23 | 63 | object has none (use -f to overwrite existing notes to the |
e73bbd96 JH |
64 | second object). This subcommand is equivalent to: |
65 | `git notes add [-f] -C $(git notes list <from-object>) <to-object>` | |
160baa0d TR |
66 | + |
67 | In `\--stdin` mode, take lines in the format | |
68 | + | |
69 | ---------- | |
70 | <from-object> SP <to-object> [ SP <rest> ] LF | |
71 | ---------- | |
72 | + | |
73 | on standard input, and copy the notes from each <from-object> to its | |
74 | corresponding <to-object>. (The optional `<rest>` is ignored so that | |
75 | the command can read the input given to the `post-rewrite` hook.) | |
e73bbd96 | 76 | |
2347fae5 JH |
77 | append:: |
78 | Append to the notes of an existing object (defaults to HEAD). | |
79 | Creates a new notes object if needed. | |
80 | ||
65d9fb48 | 81 | edit:: |
7d541174 | 82 | Edit the notes for a given object (defaults to HEAD). |
65d9fb48 JS |
83 | |
84 | show:: | |
7d541174 | 85 | Show the notes for a given object (defaults to HEAD). |
65d9fb48 | 86 | |
92b3385f | 87 | remove:: |
7d541174 | 88 | Remove the notes for a given object (defaults to HEAD). |
92b3385f JH |
89 | This is equivalent to specifying an empty note message to |
90 | the `edit` subcommand. | |
91 | ||
d6576e1f JH |
92 | prune:: |
93 | Remove all notes for non-existing/unreachable objects. | |
65d9fb48 | 94 | |
d9246d43 JH |
95 | OPTIONS |
96 | ------- | |
7aa4754e JH |
97 | -f:: |
98 | --force:: | |
99 | When adding notes to an object that already has notes, | |
100 | overwrite the existing notes (instead of aborting). | |
101 | ||
d9246d43 | 102 | -m <msg>:: |
ba20f15e | 103 | --message=<msg>:: |
d9246d43 | 104 | Use the given note message (instead of prompting). |
cd067d3b JH |
105 | If multiple `-m` options are given, their values |
106 | are concatenated as separate paragraphs. | |
8d6888ec JN |
107 | Lines starting with `#` and empty lines other than a |
108 | single line between paragraphs will be stripped out. | |
d9246d43 JH |
109 | |
110 | -F <file>:: | |
ba20f15e | 111 | --file=<file>:: |
d9246d43 JH |
112 | Take the note message from the given file. Use '-' to |
113 | read the note message from the standard input. | |
8d6888ec JN |
114 | Lines starting with `#` and empty lines other than a |
115 | single line between paragraphs will be stripped out. | |
d9246d43 | 116 | |
0691cff7 JH |
117 | -C <object>:: |
118 | --reuse-message=<object>:: | |
8d6888ec JN |
119 | Take the note message from the given blob object (for |
120 | example, another note). | |
0691cff7 JH |
121 | |
122 | -c <object>:: | |
123 | --reedit-message=<object>:: | |
124 | Like '-C', but with '-c' the editor is invoked, so that | |
125 | the user can further edit the note message. | |
d9246d43 | 126 | |
dcf783a2 | 127 | --ref <ref>:: |
00979710 JN |
128 | Manipulate the notes tree in <ref>. This overrides |
129 | 'GIT_NOTES_REF' and the "core.notesRef" configuration. The ref | |
dcf783a2 TR |
130 | is taken to be in `refs/notes/` if it is not qualified. |
131 | ||
66d68199 | 132 | |
9eb3f816 JN |
133 | DISCUSSION |
134 | ---------- | |
135 | ||
136 | Commit notes are blobs containing extra information about an object | |
137 | (usually information to supplement a commit's message). These blobs | |
138 | are taken from notes refs. A notes ref is usually a branch which | |
139 | contains "files" whose paths are the object names for the objects | |
140 | they describe, with some directory separators included for performance | |
141 | reasons footnote:[Permitted pathnames have the form | |
142 | 'ab'`/`'cd'`/`'ef'`/`'...'`/`'abcdef...': a sequence of directory | |
143 | names of two hexadecimal digits each followed by a filename with the | |
144 | rest of the object ID.]. | |
66d68199 TR |
145 | |
146 | Every notes change creates a new commit at the specified notes ref. | |
147 | You can therefore inspect the history of the notes by invoking, e.g., | |
9eb3f816 JN |
148 | `git log -p notes/commits`. Currently the commit message only records |
149 | which operation triggered the update, and the commit authorship is | |
150 | determined according to the usual rules (see linkgit:git-commit[1]). | |
151 | These details may change in the future. | |
152 | ||
153 | It is also permitted for a notes ref to point directly to a tree | |
154 | object, in which case the history of the notes can be read with | |
155 | `git log -p -g <refname>`. | |
66d68199 TR |
156 | |
157 | ||
8d6888ec JN |
158 | EXAMPLES |
159 | -------- | |
160 | ||
161 | You can use notes to add annotations with information that was not | |
162 | available at the time a commit was written. | |
163 | ||
164 | ------------ | |
165 | $ git notes add -m 'Tested-by: Johannes Sixt <j6t@kdbg.org>' 72a144e2 | |
166 | $ git show -s 72a144e | |
167 | [...] | |
168 | Signed-off-by: Junio C Hamano <gitster@pobox.com> | |
169 | ||
170 | Notes: | |
171 | Tested-by: Johannes Sixt <j6t@kdbg.org> | |
172 | ------------ | |
173 | ||
174 | In principle, a note is a regular Git blob, and any kind of | |
175 | (non-)format is accepted. You can binary-safely create notes from | |
176 | arbitrary files using 'git hash-object': | |
177 | ||
178 | ------------ | |
179 | $ cc *.c | |
180 | $ blob=$(git hash-object -w a.out) | |
181 | $ git notes --ref=built add -C "$blob" HEAD | |
182 | ------------ | |
183 | ||
184 | Of course, it doesn't make much sense to display non-text-format notes | |
185 | with 'git log', so if you use such notes, you'll probably need to write | |
186 | some special-purpose tools to do something useful with them. | |
187 | ||
188 | ||
ed9098fd JN |
189 | CONFIGURATION |
190 | ------------- | |
191 | ||
192 | core.notesRef:: | |
00979710 JN |
193 | Notes ref to read and manipulate instead of |
194 | `refs/notes/commits`. Must be an unabbreviated ref name. | |
195 | This setting can be overridden through the environment and | |
196 | command line. | |
ed9098fd JN |
197 | |
198 | notes.displayRef:: | |
66c4c32d JN |
199 | Which ref (or refs, if a glob or specified more than once), in |
200 | addition to the default set by `core.notesRef` or | |
201 | 'GIT_NOTES_REF', to read notes from when showing commit | |
202 | messages with the 'git log' family of commands. | |
203 | This setting can be overridden on the command line or by the | |
204 | 'GIT_NOTES_DISPLAY_REF' environment variable. | |
205 | See linkgit:git-log[1]. | |
ed9098fd JN |
206 | |
207 | notes.rewrite.<command>:: | |
208 | When rewriting commits with <command> (currently `amend` or | |
209 | `rebase`) and this variable is set to `true`, git | |
210 | automatically copies your notes from the original to the | |
211 | rewritten commit. Defaults to `true`, but see | |
212 | "notes.rewriteRef" below. | |
213 | ||
214 | notes.rewriteMode:: | |
215 | When copying notes during a rewrite (see the | |
216 | "notes.rewrite.<command>" option), determines what to do if | |
217 | the target commit already has a note. Must be one of | |
218 | `overwrite`, `concatenate`, or `ignore`. Defaults to | |
219 | `concatenate`. | |
220 | + | |
221 | This setting can be overridden with the `GIT_NOTES_REWRITE_MODE` | |
222 | environment variable. | |
223 | ||
224 | notes.rewriteRef:: | |
225 | When copying notes during a rewrite, specifies the (fully | |
226 | qualified) ref whose notes should be copied. The ref may be a | |
227 | glob, in which case notes in all matching refs will be copied. | |
228 | You may also specify this configuration several times. | |
229 | + | |
230 | Does not have a default value; you must configure this variable to | |
231 | enable note rewriting. | |
232 | + | |
233 | This setting can be overridden with the `GIT_NOTES_REWRITE_REF` | |
234 | environment variable, which must be a colon separated list of refs or | |
235 | globs. | |
236 | ||
00979710 JN |
237 | |
238 | ENVIRONMENT | |
239 | ----------- | |
240 | ||
241 | 'GIT_NOTES_REF':: | |
242 | Which ref to manipulate notes from, instead of `refs/notes/commits`. | |
243 | This overrides the `core.notesRef` setting. | |
244 | ||
66c4c32d JN |
245 | 'GIT_NOTES_DISPLAY_REF':: |
246 | Colon-delimited list of refs or globs indicating which refs, | |
247 | in addition to the default from `core.notesRef` or | |
248 | 'GIT_NOTES_REF', to read notes from when showing commit | |
249 | messages. | |
250 | This overrides the `notes.displayRef` setting. | |
251 | + | |
252 | A warning will be issued for refs that do not exist, but a glob that | |
253 | does not match any refs is silently ignored. | |
254 | ||
00979710 | 255 | |
65d9fb48 JS |
256 | Author |
257 | ------ | |
7d541174 JH |
258 | Written by Johannes Schindelin <johannes.schindelin@gmx.de> and |
259 | Johan Herland <johan@herland.net> | |
65d9fb48 JS |
260 | |
261 | Documentation | |
262 | ------------- | |
7d541174 | 263 | Documentation by Johannes Schindelin and Johan Herland |
65d9fb48 JS |
264 | |
265 | GIT | |
266 | --- | |
267 | Part of the linkgit:git[7] suite |