1 <?xml version="1.0" encoding="UTF-8"?>
\r
2 <!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
\r
4 <article lang="en" id="git-notes(1)">
\r
6 <title>git-notes(1)</title>
\r
8 <primary>git-notes(1)</primary>
\r
11 <simplesect id="_name">
\r
13 <simpara>git-notes - Add or inspect object notes</simpara>
\r
15 <simplesect id="_synopsis">
\r
16 <title>SYNOPSIS</title>
\r
18 <literallayout><emphasis>git notes</emphasis> [list [<object>]]
\r
19 <emphasis>git notes</emphasis> add [-f] [-F <file> | -m <msg> | (-c | -C) <object>] [<object>]
\r
20 <emphasis>git notes</emphasis> copy [-f] ( --stdin | <from-object> <to-object> )
\r
21 <emphasis>git notes</emphasis> append [-F <file> | -m <msg> | (-c | -C) <object>] [<object>]
\r
22 <emphasis>git notes</emphasis> edit [<object>]
\r
23 <emphasis>git notes</emphasis> show [<object>]
\r
24 <emphasis>git notes</emphasis> merge [-v | -q] [-s <strategy> ] <notes_ref>
\r
25 <emphasis>git notes</emphasis> merge --commit [-v | -q]
\r
26 <emphasis>git notes</emphasis> merge --abort [-v | -q]
\r
27 <emphasis>git notes</emphasis> remove [--ignore-missing] [--stdin] [<object>…]
\r
28 <emphasis>git notes</emphasis> prune [-n | -v]
\r
29 <emphasis>git notes</emphasis> get-ref</literallayout>
\r
32 <simplesect id="_description">
\r
33 <title>DESCRIPTION</title>
\r
34 <simpara>Adds, removes, or reads notes attached to objects, without touching
\r
35 the objects themselves.</simpara>
\r
36 <simpara>By default, notes are saved to and read from <emphasis>refs/notes/commits</emphasis>, but
\r
37 this default can be overridden. See the OPTIONS, CONFIGURATION, and
\r
38 ENVIRONMENT sections below. If this ref does not exist, it will be
\r
39 quietly created when it is first needed to store a note.</simpara>
\r
40 <simpara>A typical use of notes is to supplement a commit message without
\r
41 changing the commit itself. Notes can be shown by <emphasis>git log</emphasis> along with
\r
42 the original commit message. To distinguish these notes from the
\r
43 message stored in the commit object, the notes are indented like the
\r
44 message, after an unindented line saying "Notes (<refname>):" (or
\r
45 "Notes:" for <emphasis>refs/notes/commits</emphasis>).</simpara>
\r
46 <simpara>To change which notes are shown by <emphasis>git log</emphasis>, see the
\r
47 "notes.displayRef" configuration in <xref linkend="git-log(1)" />.</simpara>
\r
48 <simpara>See the "notes.rewrite.<command>" configuration for a way to carry
\r
49 notes across commands that rewrite commits.</simpara>
\r
51 <simplesect id="_subcommands">
\r
52 <title>SUBCOMMANDS</title>
\r
60 List the notes object for a given object. If no object is
\r
61 given, show a list of all note objects and the objects they
\r
62 annotate (in the format "<note object> <annotated object>").
\r
63 This is the default subcommand if no subcommand is given.
\r
73 Add notes for a given object (defaults to HEAD). Abort if the
\r
74 object already has notes (use <emphasis>-f</emphasis> to overwrite existing notes).
\r
75 However, if you're using <emphasis>add</emphasis> interactively (using an editor
\r
76 to supply the notes contents), then - instead of aborting -
\r
77 the existing notes will be opened in the editor (like the <emphasis>edit</emphasis>
\r
88 Copy the notes for the first object onto the second object.
\r
89 Abort if the second object already has notes, or if the first
\r
90 object has none (use -f to overwrite existing notes to the
\r
91 second object). This subcommand is equivalent to:
\r
92 <emphasis>git notes add [-f] -C $(git notes list <from-object>) <to-object></emphasis>
\r
94 <simpara>In <emphasis>--stdin</emphasis> mode, take lines in the format</simpara>
\r
95 <screen><from-object> SP <to-object> [ SP <rest> ] LF</screen>
\r
96 <simpara>on standard input, and copy the notes from each <from-object> to its
\r
97 corresponding <to-object>. (The optional <emphasis><rest></emphasis> is ignored so that
\r
98 the command can read the input given to the <emphasis>post-rewrite</emphasis> hook.)</simpara>
\r
107 Append to the notes of an existing object (defaults to HEAD).
\r
108 Creates a new notes object if needed.
\r
118 Edit the notes for a given object (defaults to HEAD).
\r
128 Show the notes for a given object (defaults to HEAD).
\r
138 Merge the given notes ref into the current notes ref.
\r
139 This will try to merge the changes made by the given
\r
140 notes ref (called "remote") since the merge-base (if
\r
141 any) into the current notes ref (called "local").
\r
143 <simpara>If conflicts arise and a strategy for automatically resolving
\r
144 conflicting notes (see the -s/--strategy option) is not given,
\r
145 the "manual" resolver is used. This resolver checks out the
\r
146 conflicting notes in a special worktree (<emphasis>.git/NOTES_MERGE_WORKTREE</emphasis>),
\r
147 and instructs the user to manually resolve the conflicts there.
\r
148 When done, the user can either finalize the merge with
\r
149 <emphasis>git notes merge --commit</emphasis>, or abort the merge with
\r
150 <emphasis>git notes merge --abort</emphasis>.</simpara>
\r
159 Remove the notes for given objects (defaults to HEAD). When
\r
160 giving zero or one object from the command line, this is
\r
161 equivalent to specifying an empty note message to
\r
162 the <emphasis>edit</emphasis> subcommand.
\r
172 Remove all notes for non-existing/unreachable objects.
\r
182 Print the current notes ref. This provides an easy way to
\r
183 retrieve the current notes ref (e.g. from scripts).
\r
189 <simplesect id="_options">
\r
190 <title>OPTIONS</title>
\r
201 When adding notes to an object that already has notes,
\r
202 overwrite the existing notes (instead of aborting).
\r
211 --message=<msg>
\r
215 Use the given note message (instead of prompting).
\r
216 If multiple <emphasis>-m</emphasis> options are given, their values
\r
217 are concatenated as separate paragraphs.
\r
218 Lines starting with <emphasis>#</emphasis> and empty lines other than a
\r
219 single line between paragraphs will be stripped out.
\r
228 --file=<file>
\r
232 Take the note message from the given file. Use <emphasis>-</emphasis> to
\r
233 read the note message from the standard input.
\r
234 Lines starting with <emphasis>#</emphasis> and empty lines other than a
\r
235 single line between paragraphs will be stripped out.
\r
244 --reuse-message=<object>
\r
248 Take the given blob object (for example, another note) as the
\r
249 note message. (Use <emphasis>git notes copy <object></emphasis> instead to
\r
250 copy notes between objects.)
\r
259 --reedit-message=<object>
\r
263 Like <emphasis>-C</emphasis>, but with <emphasis>-c</emphasis> the editor is invoked, so that
\r
264 the user can further edit the note message.
\r
274 Manipulate the notes tree in <ref>. This overrides
\r
275 <emphasis>GIT_NOTES_REF</emphasis> and the "core.notesRef" configuration. The ref
\r
276 is taken to be in <emphasis>refs/notes/</emphasis> if it is not qualified.
\r
286 Do not consider it an error to request removing notes from an
\r
287 object that does not have notes attached to it.
\r
297 Also read the object names to remove notes from from the standard
\r
298 input (there is no reason you cannot combine this with object
\r
299 names from the command line).
\r
312 Do not remove anything; just report the object names whose notes
\r
319 -s <strategy>
\r
322 --strategy=<strategy>
\r
326 When merging notes, resolve notes conflicts using the given
\r
327 strategy. The following strategies are recognized: "manual"
\r
328 (default), "ours", "theirs", "union" and "cat_sort_uniq".
\r
329 See the "NOTES MERGE STRATEGIES" section below for more
\r
330 information on each notes merge strategy.
\r
340 Finalize an in-progress <emphasis>git notes merge</emphasis>. Use this option
\r
341 when you have resolved the conflicts that <emphasis>git notes merge</emphasis>
\r
342 stored in .git/NOTES_MERGE_WORKTREE. This amends the partial
\r
343 merge commit created by <emphasis>git notes merge</emphasis> (stored in
\r
344 .git/NOTES_MERGE_PARTIAL) by adding the notes in
\r
345 .git/NOTES_MERGE_WORKTREE. The notes ref stored in the
\r
346 .git/NOTES_MERGE_REF symref is updated to the resulting commit.
\r
356 Abort/reset a in-progress <emphasis>git notes merge</emphasis>, i.e. a notes merge
\r
357 with conflicts. This simply removes all files related to the
\r
371 When merging notes, operate quietly.
\r
384 When merging notes, be more verbose.
\r
385 When pruning notes, report all object names whose notes are
\r
392 <simplesect id="_discussion">
\r
393 <title>DISCUSSION</title>
\r
394 <simpara>Commit notes are blobs containing extra information about an object
\r
395 (usually information to supplement a commit's message). These blobs
\r
396 are taken from notes refs. A notes ref is usually a branch which
\r
397 contains "files" whose paths are the object names for the objects
\r
398 they describe, with some directory separators included for performance
\r
399 reasons <footnote><simpara>Permitted pathnames have the form
\r
400 <emphasis>ab</emphasis><emphasis>/</emphasis><emphasis>cd</emphasis><emphasis>/</emphasis><emphasis>ef</emphasis><emphasis>/</emphasis><emphasis>…</emphasis><emphasis>/</emphasis><emphasis>abcdef…</emphasis>: a sequence of directory
\r
401 names of two hexadecimal digits each followed by a filename with the
\r
402 rest of the object ID.</simpara></footnote>.</simpara>
\r
403 <simpara>Every notes change creates a new commit at the specified notes ref.
\r
404 You can therefore inspect the history of the notes by invoking, e.g.,
\r
405 <emphasis>git log -p notes/commits</emphasis>. Currently the commit message only records
\r
406 which operation triggered the update, and the commit authorship is
\r
407 determined according to the usual rules (see <xref linkend="git-commit(1)" />).
\r
408 These details may change in the future.</simpara>
\r
409 <simpara>It is also permitted for a notes ref to point directly to a tree
\r
410 object, in which case the history of the notes can be read with
\r
411 <emphasis>git log -p -g <refname></emphasis>.</simpara>
\r
413 <simplesect id="_notes_merge_strategies">
\r
414 <title>NOTES MERGE STRATEGIES</title>
\r
415 <simpara>The default notes merge strategy is "manual", which checks out
\r
416 conflicting notes in a special work tree for resolving notes conflicts
\r
417 (<emphasis>.git/NOTES_MERGE_WORKTREE</emphasis>), and instructs the user to resolve the
\r
418 conflicts in that work tree.
\r
419 When done, the user can either finalize the merge with
\r
420 <emphasis>git notes merge --commit</emphasis>, or abort the merge with
\r
421 <emphasis>git notes merge --abort</emphasis>.</simpara>
\r
422 <simpara>"ours" automatically resolves conflicting notes in favor of the local
\r
423 version (i.e. the current notes ref).</simpara>
\r
424 <simpara>"theirs" automatically resolves notes conflicts in favor of the remote
\r
425 version (i.e. the given notes ref being merged into the current notes
\r
427 <simpara>"union" automatically resolves notes conflicts by concatenating the
\r
428 local and remote versions.</simpara>
\r
429 <simpara>"cat_sort_uniq" is similar to "union", but in addition to concatenating
\r
430 the local and remote versions, this strategy also sorts the resulting
\r
431 lines, and removes duplicate lines from the result. This is equivalent
\r
432 to applying the "cat | sort | uniq" shell pipeline to the local and
\r
433 remote versions. This strategy is useful if the notes follow a line-based
\r
434 format where one wants to avoid duplicated lines in the merge result.
\r
435 Note that if either the local or remote version contain duplicate lines
\r
436 prior to the merge, these will also be removed by this notes merge
\r
437 strategy.</simpara>
\r
439 <simplesect id="_examples">
\r
440 <title>EXAMPLES</title>
\r
441 <simpara>You can use notes to add annotations with information that was not
\r
442 available at the time a commit was written.</simpara>
\r
443 <screen>$ git notes add -m 'Tested-by: Johannes Sixt <j6t@kdbg.org>' 72a144e2
\r
444 $ git show -s 72a144e
\r
446 Signed-off-by: Junio C Hamano <gitster@pobox.com>
\r
449 Tested-by: Johannes Sixt <j6t@kdbg.org></screen>
\r
450 <simpara>In principle, a note is a regular Git blob, and any kind of
\r
451 (non-)format is accepted. You can binary-safely create notes from
\r
452 arbitrary files using <emphasis>git hash-object</emphasis>:</simpara>
\r
454 $ blob=$(git hash-object -w a.out)
\r
455 $ git notes --ref=built add -C "$blob" HEAD</screen>
\r
456 <simpara>(You cannot simply use <emphasis>git notes --ref=built add -F a.out HEAD</emphasis>
\r
457 because that is not binary-safe.)
\r
458 Of course, it doesn't make much sense to display non-text-format notes
\r
459 with <emphasis>git log</emphasis>, so if you use such notes, you'll probably need to write
\r
460 some special-purpose tools to do something useful with them.</simpara>
\r
462 <simplesect id="_configuration">
\r
463 <title>CONFIGURATION</title>
\r
471 Notes ref to read and manipulate instead of
\r
472 <emphasis>refs/notes/commits</emphasis>. Must be an unabbreviated ref name.
\r
473 This setting can be overridden through the environment and
\r
484 Which ref (or refs, if a glob or specified more than once), in
\r
485 addition to the default set by <emphasis>core.notesRef</emphasis> or
\r
486 <emphasis>GIT_NOTES_REF</emphasis>, to read notes from when showing commit
\r
487 messages with the <emphasis>git log</emphasis> family of commands.
\r
488 This setting can be overridden on the command line or by the
\r
489 <emphasis>GIT_NOTES_DISPLAY_REF</emphasis> environment variable.
\r
490 See <xref linkend="git-log(1)" />.
\r
496 notes.rewrite.<command>
\r
500 When rewriting commits with <command> (currently <emphasis>amend</emphasis> or
\r
501 <emphasis>rebase</emphasis>), if this variable is <emphasis>false</emphasis>, git will not copy
\r
502 notes from the original to the rewritten commit. Defaults to
\r
503 <emphasis>true</emphasis>. See also "<emphasis>notes.rewriteRef</emphasis>" below.
\r
505 <simpara>This setting can be overridden by the <emphasis>GIT_NOTES_REWRITE_REF</emphasis>
\r
506 environment variable.</simpara>
\r
515 When copying notes during a rewrite, what to do if the target
\r
516 commit already has a note. Must be one of <emphasis>overwrite</emphasis>,
\r
517 <emphasis>concatenate</emphasis>, and <emphasis>ignore</emphasis>. Defaults to <emphasis>concatenate</emphasis>.
\r
519 <simpara>This setting can be overridden with the <emphasis>GIT_NOTES_REWRITE_MODE</emphasis>
\r
520 environment variable.</simpara>
\r
529 When copying notes during a rewrite, specifies the (fully
\r
530 qualified) ref whose notes should be copied. May be a glob,
\r
531 in which case notes in all matching refs will be copied. You
\r
532 may also specify this configuration several times.
\r
534 <simpara>Does not have a default value; you must configure this variable to
\r
535 enable note rewriting.</simpara>
\r
536 <simpara>Can be overridden with the <emphasis>GIT_NOTES_REWRITE_REF</emphasis> environment variable.</simpara>
\r
541 <simplesect id="_environment">
\r
542 <title>ENVIRONMENT</title>
\r
546 <emphasis>GIT_NOTES_REF</emphasis>
\r
550 Which ref to manipulate notes from, instead of <emphasis>refs/notes/commits</emphasis>.
\r
551 This overrides the <emphasis>core.notesRef</emphasis> setting.
\r
557 <emphasis>GIT_NOTES_DISPLAY_REF</emphasis>
\r
561 Colon-delimited list of refs or globs indicating which refs,
\r
562 in addition to the default from <emphasis>core.notesRef</emphasis> or
\r
563 <emphasis>GIT_NOTES_REF</emphasis>, to read notes from when showing commit
\r
565 This overrides the <emphasis>notes.displayRef</emphasis> setting.
\r
567 <simpara>A warning will be issued for refs that do not exist, but a glob that
\r
568 does not match any refs is silently ignored.</simpara>
\r
573 <emphasis>GIT_NOTES_REWRITE_MODE</emphasis>
\r
577 When copying notes during a rewrite, what to do if the target
\r
578 commit already has a note.
\r
579 Must be one of <emphasis>overwrite</emphasis>, <emphasis>concatenate</emphasis>, and <emphasis>ignore</emphasis>.
\r
580 This overrides the <emphasis>core.rewriteMode</emphasis> setting.
\r
586 <emphasis>GIT_NOTES_REWRITE_REF</emphasis>
\r
590 When rewriting commits, which notes to copy from the original
\r
591 to the rewritten commit. Must be a colon-delimited list of
\r
594 <simpara>If not set in the environment, the list of notes to copy depends
\r
595 on the <emphasis>notes.rewrite.<command></emphasis> and <emphasis>notes.rewriteRef</emphasis> settings.</simpara>
\r
600 <simplesect id="_author">
\r
601 <title>Author</title>
\r
602 <simpara>Written by Johannes Schindelin <<ulink url="mailto:johannes.schindelin@gmx.de">johannes.schindelin@gmx.de</ulink>> and
\r
603 Johan Herland <<ulink url="mailto:johan@herland.net">johan@herland.net</ulink>></simpara>
\r
605 <simplesect id="_documentation">
\r
606 <title>Documentation</title>
\r
607 <simpara>Documentation by Johannes Schindelin and Johan Herland</simpara>
\r
609 <simplesect id="_git">
\r
611 <simpara>Part of the <xref linkend="git(7)" /> suite</simpara>
\r