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] [--allow-empty] [-F <file> | -m <msg> | (-c | -C) <object>] [<object>]
11 git notes copy [-f] ( --stdin | <from-object> <to-object> )
12 git notes append [--allow-empty] [-F <file> | -m <msg> | (-c | -C) <object>] [<object>]
13 git notes edit [--allow-empty] [<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 "NOTES MERGE STRATEGIES" section) is not
98 given, the "manual" resolver is used. This resolver checks out the
99 conflicting notes in a special worktree
100 (.git/NOTES_MERGE_WORKTREE), and instructs the user to manually
101 resolve the conflicts there. When done, the user can either
102 finalize the merge with git notes merge --commit, or abort the
103 merge with git notes merge --abort.
104
105 remove
106 Remove the notes for given objects (defaults to HEAD). When giving
107 zero or one object from the command line, this is equivalent to
108 specifying an empty note message to the edit subcommand.
109
110 prune
111 Remove all notes for non-existing/unreachable objects.
112
113 get-ref
114 Print the current notes ref. This provides an easy way to retrieve
115 the current notes ref (e.g. from scripts).
116
118 -f, --force
119 When adding notes to an object that already has notes, overwrite
120 the existing notes (instead of aborting).
121
122 -m <msg>, --message=<msg>
123 Use the given note message (instead of prompting). If multiple -m
124 options are given, their values are concatenated as separate
125 paragraphs. Lines starting with # and empty lines other than a
126 single line between paragraphs will be stripped out.
127
128 -F <file>, --file=<file>
129 Take the note message from the given file. Use - to read the note
130 message from the standard input. Lines starting with # and empty
131 lines other than a single line between paragraphs will be stripped
132 out.
133
134 -C <object>, --reuse-message=<object>
135 Take the given blob object (for example, another note) as the note
136 message. (Use git notes copy <object> instead to copy notes between
137 objects.)
138
139 -c <object>, --reedit-message=<object>
140 Like -C, but with -c the editor is invoked, so that the user can
141 further edit the note message.
142
143 --allow-empty
144 Allow an empty note object to be stored. The default behavior is to
145 automatically remove empty notes.
146
147 --ref <ref>
148 Manipulate the notes tree in <ref>. This overrides GIT_NOTES_REF
149 and the "core.notesRef" configuration. The ref specifies the full
150 refname when it begins with refs/notes/; when it begins with
151 notes/, refs/ and otherwise refs/notes/ is prefixed to form a full
152 name of the ref.
153
154 --ignore-missing
155 Do not consider it an error to request removing notes from an
156 object that does not have notes attached to it.
157
158 --stdin
159 Also read the object names to remove notes from the standard input
160 (there is no reason you cannot combine this with object names from
161 the command line).
162
163 -n, --dry-run
164 Do not remove anything; just report the object names whose notes
165 would be removed.
166
167 -s <strategy>, --strategy=<strategy>
168 When merging notes, resolve notes conflicts using the given
169 strategy. The following strategies are recognized: "manual"
170 (default), "ours", "theirs", "union" and "cat_sort_uniq". This
171 option overrides the "notes.mergeStrategy" configuration setting.
172 See the "NOTES MERGE STRATEGIES" section below for more information
173 on each notes merge strategy.
174
175 --commit
176 Finalize an in-progress git notes merge. Use this option when you
177 have resolved the conflicts that git notes merge stored in
178 .git/NOTES_MERGE_WORKTREE. This amends the partial merge commit
179 created by git notes merge (stored in .git/NOTES_MERGE_PARTIAL) by
180 adding the notes in .git/NOTES_MERGE_WORKTREE. The notes ref stored
181 in the .git/NOTES_MERGE_REF symref is updated to the resulting
182 commit.
183
184 --abort
185 Abort/reset a in-progress git notes merge, i.e. a notes merge with
186 conflicts. This simply removes all files related to the notes
187 merge.
188
189 -q, --quiet
190 When merging notes, operate quietly.
191
192 -v, --verbose
193 When merging notes, be more verbose. When pruning notes, report all
194 object names whose notes are removed.
195
197 Commit notes are blobs containing extra information about an object
198 (usually information to supplement a commit’s message). These blobs are
199 taken from notes refs. A notes ref is usually a branch which contains
200 "files" whose paths are the object names for the objects they describe,
201 with some directory separators included for performance reasons [1].
202
203 Every notes change creates a new commit at the specified notes ref. You
204 can therefore inspect the history of the notes by invoking, e.g., git
205 log -p notes/commits. Currently the commit message only records which
206 operation triggered the update, and the commit authorship is determined
207 according to the usual rules (see git-commit(1)). These details may
208 change in the future.
209
210 It is also permitted for a notes ref to point directly to a tree
211 object, in which case the history of the notes can be read with git log
212 -p -g <refname>.
213
215 The default notes merge strategy is "manual", which checks out
216 conflicting notes in a special work tree for resolving notes conflicts
217 (.git/NOTES_MERGE_WORKTREE), and instructs the user to resolve the
218 conflicts in that work tree. When done, the user can either finalize
219 the merge with git notes merge --commit, or abort the merge with git
220 notes merge --abort.
221
222 Users may select an automated merge strategy from among the following
223 using either -s/--strategy option or configuring notes.mergeStrategy
224 accordingly:
225
226 "ours" automatically resolves conflicting notes in favor of the local
227 version (i.e. the current notes ref).
228
229 "theirs" automatically resolves notes conflicts in favor of the remote
230 version (i.e. the given notes ref being merged into the current notes
231 ref).
232
233 "union" automatically resolves notes conflicts by concatenating the
234 local and remote versions.
235
236 "cat_sort_uniq" is similar to "union", but in addition to concatenating
237 the local and remote versions, this strategy also sorts the resulting
238 lines, and removes duplicate lines from the result. This is equivalent
239 to applying the "cat | sort | uniq" shell pipeline to the local and
240 remote versions. This strategy is useful if the notes follow a
241 line-based format where one wants to avoid duplicated lines in the
242 merge result. Note that if either the local or remote version contain
243 duplicate lines prior to the merge, these will also be removed by this
244 notes merge strategy.
245
247 You can use notes to add annotations with information that was not
248 available at the time a commit was written.
249
250 $ git notes add -m 'Tested-by: Johannes Sixt <j6t@kdbg.org>' 72a144e2
251 $ git show -s 72a144e
252 [...]
253 Signed-off-by: Junio C Hamano <gitster@pobox.com>
254
255 Notes:
256 Tested-by: Johannes Sixt <j6t@kdbg.org>
257
258
259 In principle, a note is a regular Git blob, and any kind of
260 (non-)format is accepted. You can binary-safely create notes from
261 arbitrary files using git hash-object:
262
263 $ cc *.c
264 $ blob=$(git hash-object -w a.out)
265 $ git notes --ref=built add --allow-empty -C "$blob" HEAD
266
267
268 (You cannot simply use git notes --ref=built add -F a.out HEAD because
269 that is not binary-safe.) Of course, it doesn’t make much sense to
270 display non-text-format notes with git log, so if you use such notes,
271 you’ll probably need to write some special-purpose tools to do
272 something useful with them.
273
275 core.notesRef
276 Notes ref to read and manipulate instead of refs/notes/commits.
277 Must be an unabbreviated ref name. This setting can be overridden
278 through the environment and command line.
279
280 notes.mergeStrategy
281 Which merge strategy to choose by default when resolving notes
282 conflicts. Must be one of manual, ours, theirs, union, or
283 cat_sort_uniq. Defaults to manual. See "NOTES MERGE STRATEGIES"
284 section above for more information on each strategy.
285
286 This setting can be overridden by passing the --strategy option.
287
288 notes.<name>.mergeStrategy
289 Which merge strategy to choose when doing a notes merge into
290 refs/notes/<name>. This overrides the more general
291 "notes.mergeStrategy". See the "NOTES MERGE STRATEGIES" section
292 above for more information on each available strategy.
293
294 notes.displayRef
295 Which ref (or refs, if a glob or specified more than once), in
296 addition to the default set by core.notesRef or GIT_NOTES_REF, to
297 read notes from when showing commit messages with the git log
298 family of commands. This setting can be overridden on the command
299 line or by the GIT_NOTES_DISPLAY_REF environment variable. See git-
300 log(1).
301
302 notes.rewrite.<command>
303 When rewriting commits with <command> (currently amend or rebase),
304 if this variable is false, git will not copy notes from the
305 original to the rewritten commit. Defaults to true. See also
306 "notes.rewriteRef" below.
307
308 This setting can be overridden by the GIT_NOTES_REWRITE_REF
309 environment variable.
310
311 notes.rewriteMode
312 When copying notes during a rewrite, what to do if the target
313 commit already has a note. Must be one of overwrite, concatenate,
314 cat_sort_uniq, or ignore. Defaults to concatenate.
315
316 This setting can be overridden with the GIT_NOTES_REWRITE_MODE
317 environment variable.
318
319 notes.rewriteRef
320 When copying notes during a rewrite, specifies the (fully
321 qualified) ref whose notes should be copied. May be a glob, in
322 which case notes in all matching refs will be copied. You may also
323 specify this configuration several times.
324
325 Does not have a default value; you must configure this variable to
326 enable note rewriting.
327
328 Can be overridden with the GIT_NOTES_REWRITE_REF environment
329 variable.
330
332 GIT_NOTES_REF
333 Which ref to manipulate notes from, instead of refs/notes/commits.
334 This overrides the core.notesRef setting.
335
336 GIT_NOTES_DISPLAY_REF
337 Colon-delimited list of refs or globs indicating which refs, in
338 addition to the default from core.notesRef or GIT_NOTES_REF, to
339 read notes from when showing commit messages. This overrides the
340 notes.displayRef setting.
341
342 A warning will be issued for refs that do not exist, but a glob
343 that does not match any refs is silently ignored.
344
345 GIT_NOTES_REWRITE_MODE
346 When copying notes during a rewrite, what to do if the target
347 commit already has a note. Must be one of overwrite, concatenate,
348 cat_sort_uniq, or ignore. This overrides the core.rewriteMode
349 setting.
350
351 GIT_NOTES_REWRITE_REF
352 When rewriting commits, which notes to copy from the original to
353 the rewritten commit. Must be a colon-delimited list of refs or
354 globs.
355
356 If not set in the environment, the list of notes to copy depends on
357 the notes.rewrite.<command> and notes.rewriteRef settings.
358
360 Part of the git(1) suite
361
363 1. Permitted pathnames have the form ab/cd/ef/.../abcdef...: a
364 sequence of directory names of two hexadecimal digits each followed
365 by a filename with the rest of the object ID.
366
367
368
369
370Git 2.18.1 05/14/2019 GIT-NOTES(1)