blob: 0a4200674c40af473d135ccd5df129f28a684864 [file] [log] [blame]
Junio C Hamano3b70d3c2009-11-21 17:37:371git-notes(1)
2============
3
4NAME
5----
Junio C Hamanoa574a092010-06-13 19:57:106git-notes - Add or inspect object notes
Junio C Hamano3b70d3c2009-11-21 17:37:377
8SYNOPSIS
9--------
10[verse]
Junio C Hamanoea90ab32010-03-15 20:32:5511'git notes' [list [<object>]]
Junio C Hamanofad84122014-12-05 23:38:0612'git notes' add [-f] [--allow-empty] [-F <file> | -m <msg> | (-c | -C) <object>] [<object>]
Junio C Hamano8ac8a3d2019-11-11 04:33:4613'git notes' copy [-f] ( --stdin | <from-object> [<to-object>] )
Junio C Hamanofad84122014-12-05 23:38:0614'git notes' append [--allow-empty] [-F <file> | -m <msg> | (-c | -C) <object>] [<object>]
15'git notes' edit [--allow-empty] [<object>]
Junio C Hamanoea90ab32010-03-15 20:32:5516'git notes' show [<object>]
Junio C Hamanod75148a2014-04-08 19:48:3817'git notes' merge [-v | -q] [-s <strategy> ] <notes-ref>
Junio C Hamano788eeba2010-12-08 22:50:4318'git notes' merge --commit [-v | -q]
19'git notes' merge --abort [-v | -q]
Junio C Hamano084228c2011-05-30 08:13:5220'git notes' remove [--ignore-missing] [--stdin] [<object>...]
Junio C Hamano912712b2017-12-06 18:04:0121'git notes' prune [-n] [-v]
Junio C Hamano788eeba2010-12-08 22:50:4322'git notes' get-ref
Junio C Hamanoea90ab32010-03-15 20:32:5523
Junio C Hamano3b70d3c2009-11-21 17:37:3724
25DESCRIPTION
26-----------
Junio C Hamanoa574a092010-06-13 19:57:1027Adds, removes, or reads notes attached to objects, without touching
28the objects themselves.
Junio C Hamano3b70d3c2009-11-21 17:37:3729
Junio C Hamanoa574a092010-06-13 19:57:1030By 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
Junio C Hamanoea90ab32010-03-15 20:32:5538message stored in the commit object, the notes are indented like the
Junio C Hamano31667362010-03-25 00:38:5339message, after an unindented line saying "Notes (<refname>):" (or
Junio C Hamanoa574a092010-06-13 19:57:1040"Notes:" for `refs/notes/commits`).
Junio C Hamanoea90ab32010-03-15 20:32:5541
Junio C Hamano4eb2b9c2012-11-15 21:12:2942Notes 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
Junio C Hamanoa574a092010-06-13 19:57:1046To change which notes are shown by 'git log', see the
47"notes.displayRef" configuration in linkgit:git-log[1].
Junio C Hamano31667362010-03-25 00:38:5348
Junio C Hamanoa574a092010-06-13 19:57:1049See the "notes.rewrite.<command>" configuration for a way to carry
50notes across commands that rewrite commits.
Junio C Hamano3b70d3c2009-11-21 17:37:3751
52
53SUBCOMMANDS
54-----------
55
Junio C Hamanoea90ab32010-03-15 20:32:5556list::
57List the notes object for a given object. If no object is
58given, show a list of all note objects and the objects they
59annotate (in the format "<note object> <annotated object>").
60This is the default subcommand if no subcommand is given.
61
62add::
63Add notes for a given object (defaults to HEAD). Abort if the
Junio C Hamano60033462011-05-03 00:48:4364object already has notes (use `-f` to overwrite existing notes).
65However, if you're using `add` interactively (using an editor
66to supply the notes contents), then - instead of aborting -
67the existing notes will be opened in the editor (like the `edit`
68subcommand).
Junio C Hamanoea90ab32010-03-15 20:32:5569
70copy::
Junio C Hamano8ac8a3d2019-11-11 04:33:4671Copy the notes for the first object onto the second object (defaults to
72HEAD). Abort if the second object already has notes, or if the first
Junio C Hamanoea90ab32010-03-15 20:32:5573object has none (use -f to overwrite existing notes to the
74second object). This subcommand is equivalent to:
75`git notes add [-f] -C $(git notes list <from-object>) <to-object>`
Junio C Hamano31667362010-03-25 00:38:5376+
Junio C Hamanob76a6862012-05-02 22:02:4677In `--stdin` mode, take lines in the format
Junio C Hamano31667362010-03-25 00:38:5378+
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.)
Junio C Hamanoea90ab32010-03-15 20:32:5586
87append::
88Append to the notes of an existing object (defaults to HEAD).
89Creates a new notes object if needed.
90
Junio C Hamano3b70d3c2009-11-21 17:37:3791edit::
Junio C Hamanoea90ab32010-03-15 20:32:5592Edit the notes for a given object (defaults to HEAD).
Junio C Hamano3b70d3c2009-11-21 17:37:3793
94show::
Junio C Hamanoea90ab32010-03-15 20:32:5595Show the notes for a given object (defaults to HEAD).
Junio C Hamano3b70d3c2009-11-21 17:37:3796
Junio C Hamano788eeba2010-12-08 22:50:4397merge::
98Merge the given notes ref into the current notes ref.
99This will try to merge the changes made by the given
100notes ref (called "remote") since the merge-base (if
101any) into the current notes ref (called "local").
102+
103If conflicts arise and a strategy for automatically resolving
Junio C Hamano3891e252015-08-31 23:06:13104conflicting notes (see the "NOTES MERGE STRATEGIES" section) is not given,
Junio C Hamano788eeba2010-12-08 22:50:43105the "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
Junio C Hamanoea90ab32010-03-15 20:32:55112remove::
Junio C Hamano084228c2011-05-30 08:13:52113Remove the notes for given objects (defaults to HEAD). When
114giving zero or one object from the command line, this is
115equivalent to specifying an empty note message to
Junio C Hamanoea90ab32010-03-15 20:32:55116the `edit` subcommand.
117
118prune::
119Remove all notes for non-existing/unreachable objects.
Junio C Hamano3b70d3c2009-11-21 17:37:37120
Junio C Hamano788eeba2010-12-08 22:50:43121get-ref::
122Print the current notes ref. This provides an easy way to
123retrieve the current notes ref (e.g. from scripts).
124
Junio C Hamano3b70d3c2009-11-21 17:37:37125OPTIONS
126-------
Junio C Hamanoea90ab32010-03-15 20:32:55127-f::
128--force::
129When adding notes to an object that already has notes,
130overwrite the existing notes (instead of aborting).
131
Junio C Hamano3b70d3c2009-11-21 17:37:37132-m <msg>::
Junio C Hamanoea90ab32010-03-15 20:32:55133--message=<msg>::
Junio C Hamano3b70d3c2009-11-21 17:37:37134Use the given note message (instead of prompting).
Junio C Hamanoea90ab32010-03-15 20:32:55135If multiple `-m` options are given, their values
136are concatenated as separate paragraphs.
Junio C Hamanoa574a092010-06-13 19:57:10137Lines starting with `#` and empty lines other than a
138single line between paragraphs will be stripped out.
Junio C Hamano3b70d3c2009-11-21 17:37:37139
140-F <file>::
Junio C Hamanoea90ab32010-03-15 20:32:55141--file=<file>::
Junio C Hamano3b70d3c2009-11-21 17:37:37142Take the note message from the given file. Use '-' to
143read the note message from the standard input.
Junio C Hamanoa574a092010-06-13 19:57:10144Lines starting with `#` and empty lines other than a
145single line between paragraphs will be stripped out.
Junio C Hamano3b70d3c2009-11-21 17:37:37146
Junio C Hamanoea90ab32010-03-15 20:32:55147-C <object>::
148--reuse-message=<object>::
Junio C Hamano6b7d2152019-04-16 12:51:15149Take the given blob object (for example, another note) as the
Junio C Hamano7bd050f2011-09-22 06:32:22150note message. (Use `git notes copy <object>` instead to
151copy notes between objects.)
Junio C Hamanoea90ab32010-03-15 20:32:55152
153-c <object>::
154--reedit-message=<object>::
Junio C Hamano92d80372016-07-13 22:00:05155Like '-C', but with `-c` the editor is invoked, so that
Junio C Hamanoea90ab32010-03-15 20:32:55156the user can further edit the note message.
Junio C Hamano3b70d3c2009-11-21 17:37:37157
Junio C Hamanofad84122014-12-05 23:38:06158--allow-empty::
159Allow an empty note object to be stored. The default behavior is
160to automatically remove empty notes.
161
Junio C Hamano31667362010-03-25 00:38:53162--ref <ref>::
Junio C Hamanoa574a092010-06-13 19:57:10163Manipulate the notes tree in <ref>. This overrides
Junio C Hamano042f2142016-06-27 18:05:05164`GIT_NOTES_REF` and the "core.notesRef" configuration. The ref
Junio C Hamano1f7c4a52015-10-14 22:15:51165specifies the full refname when it begins with `refs/notes/`; when it
166begins with `notes/`, `refs/` and otherwise `refs/notes/` is prefixed
167to form a full name of the ref.
Junio C Hamano31667362010-03-25 00:38:53168
Junio C Hamano084228c2011-05-30 08:13:52169--ignore-missing::
170Do not consider it an error to request removing notes from an
171object that does not have notes attached to it.
172
173--stdin::
Junio C Hamanod4bbec02017-09-25 07:24:53174Also read the object names to remove notes from the standard
Junio C Hamano084228c2011-05-30 08:13:52175input (there is no reason you cannot combine this with object
176names from the command line).
177
Junio C Hamanoa574a092010-06-13 19:57:10178-n::
Junio C Hamanoe85e36f2010-08-10 05:30:14179--dry-run::
Junio C Hamanoa574a092010-06-13 19:57:10180Do not remove anything; just report the object names whose notes
181would be removed.
Junio C Hamano31667362010-03-25 00:38:53182
Junio C Hamano788eeba2010-12-08 22:50:43183-s <strategy>::
184--strategy=<strategy>::
185When merging notes, resolve notes conflicts using the given
186strategy. The following strategies are recognized: "manual"
187(default), "ours", "theirs", "union" and "cat_sort_uniq".
Junio C Hamano3891e252015-08-31 23:06:13188This option overrides the "notes.mergeStrategy" configuration setting.
Junio C Hamano788eeba2010-12-08 22:50:43189See the "NOTES MERGE STRATEGIES" section below for more
190information on each notes merge strategy.
191
192--commit::
193Finalize an in-progress 'git notes merge'. Use this option
194when you have resolved the conflicts that 'git notes merge'
195stored in .git/NOTES_MERGE_WORKTREE. This amends the partial
196merge 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::
Junio C Hamanoea1ac8d2018-07-18 20:16:48202Abort/reset an in-progress 'git notes merge', i.e. a notes merge
Junio C Hamano788eeba2010-12-08 22:50:43203with conflicts. This simply removes all files related to the
204notes merge.
205
206-q::
207--quiet::
208When merging notes, operate quietly.
209
Junio C Hamanoa574a092010-06-13 19:57:10210-v::
Junio C Hamanoe85e36f2010-08-10 05:30:14211--verbose::
Junio C Hamano788eeba2010-12-08 22:50:43212When merging notes, be more verbose.
213When pruning notes, report all object names whose notes are
214removed.
Junio C Hamanoa574a092010-06-13 19:57:10215
216
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
Junio C Hamanoc9dd6422020-08-10 23:32:55226'bf'`/`'fe'`/`'30'`/`'...'`/`'680d5a...': a sequence of directory
Junio C Hamanoa574a092010-06-13 19:57:10227names of two hexadecimal digits each followed by a filename with the
228rest of the object ID.].
Junio C Hamano31667362010-03-25 00:38:53229
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.,
Junio C Hamanoa574a092010-06-13 19:57:10232`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.
Junio C Hamano31667362010-03-25 00:38:53236
Junio C Hamanoa574a092010-06-13 19:57:10237It 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>`.
240
241
Junio C Hamano788eeba2010-12-08 22:50:43242NOTES MERGE STRATEGIES
243----------------------
244
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.
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'.
252
Junio C Hamano3891e252015-08-31 23:06:13253Users may select an automated merge strategy from among the following using
254either -s/--strategy option or configuring notes.mergeStrategy accordingly:
255
Junio C Hamano788eeba2010-12-08 22:50:43256"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
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
276
Junio C Hamanoa574a092010-06-13 19:57:10277EXAMPLES
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)
Junio C Hamanofad84122014-12-05 23:38:06300$ git notes --ref=built add --allow-empty -C "$blob" HEAD
Junio C Hamanoa574a092010-06-13 19:57:10301------------
302
Junio C Hamano7bd050f2011-09-22 06:32:22303(You cannot simply use `git notes --ref=built add -F a.out HEAD`
304because that is not binary-safe.)
Junio C Hamanoa574a092010-06-13 19:57:10305Of 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
310CONFIGURATION
311-------------
312
313core.notesRef::
314Notes ref to read and manipulate instead of
315`refs/notes/commits`. Must be an unabbreviated ref name.
316This setting can be overridden through the environment and
317command line.
318
Junio C Hamano3891e252015-08-31 23:06:13319notes.mergeStrategy::
320Which merge strategy to choose by default when resolving notes
321conflicts. Must be one of `manual`, `ours`, `theirs`, `union`, or
322`cat_sort_uniq`. Defaults to `manual`. See "NOTES MERGE STRATEGIES"
323section above for more information on each strategy.
324+
325This setting can be overridden by passing the `--strategy` option.
326
327notes.<name>.mergeStrategy::
328Which merge strategy to choose when doing a notes merge into
329refs/notes/<name>. This overrides the more general
330"notes.mergeStrategy". See the "NOTES MERGE STRATEGIES" section above
331for more information on each available strategy.
332
Junio C Hamanoa574a092010-06-13 19:57:10333notes.displayRef::
334Which ref (or refs, if a glob or specified more than once), in
335addition to the default set by `core.notesRef` or
Junio C Hamano042f2142016-06-27 18:05:05336`GIT_NOTES_REF`, to read notes from when showing commit
Junio C Hamanoa574a092010-06-13 19:57:10337messages with the 'git log' family of commands.
338This setting can be overridden on the command line or by the
Junio C Hamano042f2142016-06-27 18:05:05339`GIT_NOTES_DISPLAY_REF` environment variable.
Junio C Hamanoa574a092010-06-13 19:57:10340See linkgit:git-log[1].
341
342notes.rewrite.<command>::
343When rewriting commits with <command> (currently `amend` or
344`rebase`), if this variable is `false`, git will not copy
345notes from the original to the rewritten commit. Defaults to
346`true`. See also "`notes.rewriteRef`" below.
347+
Junio C Hamano042f2142016-06-27 18:05:05348This setting can be overridden by the `GIT_NOTES_REWRITE_REF`
Junio C Hamanoa574a092010-06-13 19:57:10349environment variable.
350
351notes.rewriteMode::
352When copying notes during a rewrite, what to do if the target
353commit already has a note. Must be one of `overwrite`,
Junio C Hamano3891e252015-08-31 23:06:13354`concatenate`, `cat_sort_uniq`, or `ignore`. Defaults to
355`concatenate`.
Junio C Hamanoa574a092010-06-13 19:57:10356+
357This setting can be overridden with the `GIT_NOTES_REWRITE_MODE`
358environment variable.
359
360notes.rewriteRef::
361When copying notes during a rewrite, specifies the (fully
362qualified) ref whose notes should be copied. May be a glob,
363in which case notes in all matching refs will be copied. You
364may also specify this configuration several times.
365+
366Does not have a default value; you must configure this variable to
367enable note rewriting.
368+
Junio C Hamano042f2142016-06-27 18:05:05369Can be overridden with the `GIT_NOTES_REWRITE_REF` environment variable.
Junio C Hamanoa574a092010-06-13 19:57:10370
371
372ENVIRONMENT
373-----------
374
Junio C Hamano042f2142016-06-27 18:05:05375`GIT_NOTES_REF`::
Junio C Hamanoa574a092010-06-13 19:57:10376Which ref to manipulate notes from, instead of `refs/notes/commits`.
377This overrides the `core.notesRef` setting.
378
Junio C Hamano042f2142016-06-27 18:05:05379`GIT_NOTES_DISPLAY_REF`::
Junio C Hamanoa574a092010-06-13 19:57:10380Colon-delimited list of refs or globs indicating which refs,
381in addition to the default from `core.notesRef` or
Junio C Hamano042f2142016-06-27 18:05:05382`GIT_NOTES_REF`, to read notes from when showing commit
Junio C Hamanoa574a092010-06-13 19:57:10383messages.
384This 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
Junio C Hamano042f2142016-06-27 18:05:05389`GIT_NOTES_REWRITE_MODE`::
Junio C Hamanoa574a092010-06-13 19:57:10390When copying notes during a rewrite, what to do if the target
391commit already has a note.
Junio C Hamano3891e252015-08-31 23:06:13392Must be one of `overwrite`, `concatenate`, `cat_sort_uniq`, or `ignore`.
Junio C Hamanoa574a092010-06-13 19:57:10393This overrides the `core.rewriteMode` setting.
394
Junio C Hamano042f2142016-06-27 18:05:05395`GIT_NOTES_REWRITE_REF`::
Junio C Hamanoa574a092010-06-13 19:57:10396When rewriting commits, which notes to copy from the original
397to the rewritten commit. Must be a colon-delimited list of
398refs 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.
Junio C Hamano31667362010-03-25 00:38:53402
Junio C Hamano3b70d3c2009-11-21 17:37:37403GIT
404---
Junio C Hamano198b1f12016-05-17 22:27:24405Part of the linkgit:git[1] suite