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