1GIT-NOTES(1) Git Manual GIT-NOTES(1)
2
3
4
6 git-notes - Add or inspect object notes
7
9 git notes [list [<object>]]
10 git notes add [-f] [-F <file> | -m <msg> | (-c | -C) <object>] [<object>]
11 git notes copy [-f] ( --stdin | <from-object> <to-object> )
12 git notes append [-F <file> | -m <msg> | (-c | -C) <object>] [<object>]
13 git notes edit [<object>]
14 git notes show [<object>]
15 git notes merge [-v | -q] [-s <strategy> ] <notes_ref>
16 git notes merge --commit [-v | -q]
17 git notes merge --abort [-v | -q]
18 git notes remove [--ignore-missing] [--stdin] [<object>...]
19 git notes prune [-n | -v]
20 git notes get-ref
21
22
24 Adds, removes, or reads notes attached to objects, without touching the
25 objects themselves.
26
27 By default, notes are saved to and read from refs/notes/commits, but
28 this default can be overridden. See the OPTIONS, CONFIGURATION, and
29 ENVIRONMENT sections below. If this ref does not exist, it will be
30 quietly created when it is first needed to store a note.
31
32 A typical use of notes is to supplement a commit message without
33 changing the commit itself. Notes can be shown by git log along with
34 the original commit message. To distinguish these notes from the
35 message stored in the commit object, the notes are indented like the
36 message, after an unindented line saying "Notes (<refname>):" (or
37 "Notes:" for refs/notes/commits).
38
39 Notes can also be added to patches prepared with git format-patch by
40 using the --notes option. Such notes are added as a patch commentary
41 after a three dash separator line.
42
43 To change which notes are shown by git log, see the "notes.displayRef"
44 configuration in git-log(1).
45
46 See the "notes.rewrite.<command>" configuration for a way to carry
47 notes across commands that rewrite commits.
48
50 list
51 List the notes object for a given object. If no object is given,
52 show a list of all note objects and the objects they annotate (in
53 the format "<note object> <annotated object>"). This is the default
54 subcommand if no subcommand is given.
55
56 add
57 Add notes for a given object (defaults to HEAD). Abort if the
58 object already has notes (use -f to overwrite existing notes).
59 However, if you’re using add interactively (using an editor to
60 supply the notes contents), then - instead of aborting - the
61 existing notes will be opened in the editor (like the edit
62 subcommand).
63
64 copy
65 Copy the notes for the first object onto the second object. Abort
66 if the second object already has notes, or if the first object has
67 none (use -f to overwrite existing notes to the second object).
68 This subcommand is equivalent to: git notes add [-f] -C $(git notes
69 list <from-object>) <to-object>
70
71 In --stdin mode, take lines in the format
72
73 <from-object> SP <to-object> [ SP <rest> ] LF
74
75 on standard input, and copy the notes from each <from-object> to
76 its corresponding <to-object>. (The optional <rest> is ignored so
77 that the command can read the input given to the post-rewrite
78 hook.)
79
80 append
81 Append to the notes of an existing object (defaults to HEAD).
82 Creates a new notes object if needed.
83
84 edit
85 Edit the notes for a given object (defaults to HEAD).
86
87 show
88 Show the notes for a given object (defaults to HEAD).
89
90 merge
91 Merge the given notes ref into the current notes ref. This will try
92 to merge the changes made by the given notes ref (called "remote")
93 since the merge-base (if any) into the current notes ref (called
94 "local").
95
96 If conflicts arise and a strategy for automatically resolving
97 conflicting notes (see the -s/--strategy option) is not given, the
98 "manual" resolver is used. This resolver checks out the conflicting
99 notes in a special worktree (.git/NOTES_MERGE_WORKTREE), and
100 instructs the user to manually resolve the conflicts there. When
101 done, the user can either finalize the merge with git notes merge
102 --commit, or abort the merge with git notes merge --abort.
103
104 remove
105 Remove the notes for given objects (defaults to HEAD). When giving
106 zero or one object from the command line, this is equivalent to
107 specifying an empty note message to the edit subcommand.
108
109 prune
110 Remove all notes for non-existing/unreachable objects.
111
112 get-ref
113 Print the current notes ref. This provides an easy way to retrieve
114 the current notes ref (e.g. from scripts).
115
117 -f, --force
118 When adding notes to an object that already has notes, overwrite
119 the existing notes (instead of aborting).
120
121 -m <msg>, --message=<msg>
122 Use the given note message (instead of prompting). If multiple -m
123 options are given, their values are concatenated as separate
124 paragraphs. Lines starting with # and empty lines other than a
125 single line between paragraphs will be stripped out.
126
127 -F <file>, --file=<file>
128 Take the note message from the given file. Use - to read the note
129 message from the standard input. Lines starting with # and empty
130 lines other than a single line between paragraphs will be stripped
131 out.
132
133 -C <object>, --reuse-message=<object>
134 Take the given blob object (for example, another note) as the note
135 message. (Use git notes copy <object> instead to copy notes between
136 objects.)
137
138 -c <object>, --reedit-message=<object>
139 Like -C, but with -c the editor is invoked, so that the user can
140 further edit the note message.
141
142 --ref <ref>
143 Manipulate the notes tree in <ref>. This overrides GIT_NOTES_REF
144 and the "core.notesRef" configuration. The ref is taken to be in
145 refs/notes/ if it is not qualified.
146
147 --ignore-missing
148 Do not consider it an error to request removing notes from an
149 object that does not have notes attached to it.
150
151 --stdin
152 Also read the object names to remove notes from from the standard
153 input (there is no reason you cannot combine this with object names
154 from the command line).
155
156 -n, --dry-run
157 Do not remove anything; just report the object names whose notes
158 would be removed.
159
160 -s <strategy>, --strategy=<strategy>
161 When merging notes, resolve notes conflicts using the given
162 strategy. The following strategies are recognized: "manual"
163 (default), "ours", "theirs", "union" and "cat_sort_uniq". See the
164 "NOTES MERGE STRATEGIES" section below for more information on each
165 notes merge strategy.
166
167 --commit
168 Finalize an in-progress git notes merge. Use this option when you
169 have resolved the conflicts that git notes merge stored in
170 .git/NOTES_MERGE_WORKTREE. This amends the partial merge commit
171 created by git notes merge (stored in .git/NOTES_MERGE_PARTIAL) by
172 adding the notes in .git/NOTES_MERGE_WORKTREE. The notes ref stored
173 in the .git/NOTES_MERGE_REF symref is updated to the resulting
174 commit.
175
176 --abort
177 Abort/reset a in-progress git notes merge, i.e. a notes merge with
178 conflicts. This simply removes all files related to the notes
179 merge.
180
181 -q, --quiet
182 When merging notes, operate quietly.
183
184 -v, --verbose
185 When merging notes, be more verbose. When pruning notes, report all
186 object names whose notes are removed.
187
189 Commit notes are blobs containing extra information about an object
190 (usually information to supplement a commit’s message). These blobs are
191 taken from notes refs. A notes ref is usually a branch which contains
192 "files" whose paths are the object names for the objects they describe,
193 with some directory separators included for performance reasons [1].
194
195 Every notes change creates a new commit at the specified notes ref. You
196 can therefore inspect the history of the notes by invoking, e.g., git
197 log -p notes/commits. Currently the commit message only records which
198 operation triggered the update, and the commit authorship is determined
199 according to the usual rules (see git-commit(1)). These details may
200 change in the future.
201
202 It is also permitted for a notes ref to point directly to a tree
203 object, in which case the history of the notes can be read with git log
204 -p -g <refname>.
205
207 The default notes merge strategy is "manual", which checks out
208 conflicting notes in a special work tree for resolving notes conflicts
209 (.git/NOTES_MERGE_WORKTREE), and instructs the user to resolve the
210 conflicts in that work tree. When done, the user can either finalize
211 the merge with git notes merge --commit, or abort the merge with git
212 notes merge --abort.
213
214 "ours" automatically resolves conflicting notes in favor of the local
215 version (i.e. the current notes ref).
216
217 "theirs" automatically resolves notes conflicts in favor of the remote
218 version (i.e. the given notes ref being merged into the current notes
219 ref).
220
221 "union" automatically resolves notes conflicts by concatenating the
222 local and remote versions.
223
224 "cat_sort_uniq" is similar to "union", but in addition to concatenating
225 the local and remote versions, this strategy also sorts the resulting
226 lines, and removes duplicate lines from the result. This is equivalent
227 to applying the "cat | sort | uniq" shell pipeline to the local and
228 remote versions. This strategy is useful if the notes follow a
229 line-based format where one wants to avoid duplicated lines in the
230 merge result. Note that if either the local or remote version contain
231 duplicate lines prior to the merge, these will also be removed by this
232 notes merge strategy.
233
235 You can use notes to add annotations with information that was not
236 available at the time a commit was written.
237
238 $ git notes add -m 'Tested-by: Johannes Sixt <j6t@kdbg.org>' 72a144e2
239 $ git show -s 72a144e
240 [...]
241 Signed-off-by: Junio C Hamano <gitster@pobox.com>
242
243 Notes:
244 Tested-by: Johannes Sixt <j6t@kdbg.org>
245
246
247 In principle, a note is a regular Git blob, and any kind of
248 (non-)format is accepted. You can binary-safely create notes from
249 arbitrary files using git hash-object:
250
251 $ cc *.c
252 $ blob=$(git hash-object -w a.out)
253 $ git notes --ref=built add -C "$blob" HEAD
254
255
256 (You cannot simply use git notes --ref=built add -F a.out HEAD because
257 that is not binary-safe.) Of course, it doesn’t make much sense to
258 display non-text-format notes with git log, so if you use such notes,
259 you’ll probably need to write some special-purpose tools to do
260 something useful with them.
261
263 core.notesRef
264 Notes ref to read and manipulate instead of refs/notes/commits.
265 Must be an unabbreviated ref name. This setting can be overridden
266 through the environment and command line.
267
268 notes.displayRef
269 Which ref (or refs, if a glob or specified more than once), in
270 addition to the default set by core.notesRef or GIT_NOTES_REF, to
271 read notes from when showing commit messages with the git log
272 family of commands. This setting can be overridden on the command
273 line or by the GIT_NOTES_DISPLAY_REF environment variable. See git-
274 log(1).
275
276 notes.rewrite.<command>
277 When rewriting commits with <command> (currently amend or rebase),
278 if this variable is false, git will not copy notes from the
279 original to the rewritten commit. Defaults to true. See also
280 "notes.rewriteRef" below.
281
282 This setting can be overridden by the GIT_NOTES_REWRITE_REF
283 environment variable.
284
285 notes.rewriteMode
286 When copying notes during a rewrite, what to do if the target
287 commit already has a note. Must be one of overwrite, concatenate,
288 and ignore. Defaults to concatenate.
289
290 This setting can be overridden with the GIT_NOTES_REWRITE_MODE
291 environment variable.
292
293 notes.rewriteRef
294 When copying notes during a rewrite, specifies the (fully
295 qualified) ref whose notes should be copied. May be a glob, in
296 which case notes in all matching refs will be copied. You may also
297 specify this configuration several times.
298
299 Does not have a default value; you must configure this variable to
300 enable note rewriting.
301
302 Can be overridden with the GIT_NOTES_REWRITE_REF environment
303 variable.
304
306 GIT_NOTES_REF
307 Which ref to manipulate notes from, instead of refs/notes/commits.
308 This overrides the core.notesRef setting.
309
310 GIT_NOTES_DISPLAY_REF
311 Colon-delimited list of refs or globs indicating which refs, in
312 addition to the default from core.notesRef or GIT_NOTES_REF, to
313 read notes from when showing commit messages. This overrides the
314 notes.displayRef setting.
315
316 A warning will be issued for refs that do not exist, but a glob
317 that does not match any refs is silently ignored.
318
319 GIT_NOTES_REWRITE_MODE
320 When copying notes during a rewrite, what to do if the target
321 commit already has a note. Must be one of overwrite, concatenate,
322 and ignore. This overrides the core.rewriteMode setting.
323
324 GIT_NOTES_REWRITE_REF
325 When rewriting commits, which notes to copy from the original to
326 the rewritten commit. Must be a colon-delimited list of refs or
327 globs.
328
329 If not set in the environment, the list of notes to copy depends on
330 the notes.rewrite.<command> and notes.rewriteRef settings.
331
333 Written by Johannes Schindelin <johannes.schindelin@gmx.de[2]> and
334 Johan Herland <johan@herland.net[3]>
335
337 Documentation by Johannes Schindelin and Johan Herland
338
340 Part of the git(7) suite
341
343 1. Permitted pathnames have the form ab/cd/ef/.../abcdef...: a
344 sequence of directory names of two hexadecimal digits each followed
345 by a filename with the rest of the object ID.
346
347 2. johannes.schindelin@gmx.de
348 mailto:johannes.schindelin@gmx.de
349
350 3. johan@herland.net
351 mailto:johan@herland.net
352
353
354
355Git 1.8.3.1 11/19/2018 GIT-NOTES(1)