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