blob: f8310e56a85ab0f6f211d68b1886ec68ae126b9f [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 Hamano85a51222023-07-06 19:49:5812'git notes' add [-f] [--allow-empty] [--[no-]separator | --separator=<paragraph-break>] [--[no-]stripspace] [-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 Hamano85a51222023-07-06 19:49:5814'git notes' append [--allow-empty] [--[no-]separator | --separator=<paragraph-break>] [--[no-]stripspace] [-F <file> | -m <msg> | (-c | -C) <object>] [<object>]
15'git notes' edit [--allow-empty] [<object>] [--[no-]stripspace]
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
Junio C Hamanoba8baee2022-09-14 20:25:2347"notes.displayRef" discussion in <<CONFIGURATION>>.
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`
Junio C Hamano85a51222023-07-06 19:49:5868subcommand). If you specify multiple `-m` and `-F`, a blank
69line will be inserted between the messages. Use the `--separator`
70option to insert other delimiters.
Junio C Hamanoea90ab32010-03-15 20:32:5571
72copy::
Junio C Hamano8ac8a3d2019-11-11 04:33:4673Copy the notes for the first object onto the second object (defaults to
74HEAD). Abort if the second object already has notes, or if the first
Junio C Hamanoea90ab32010-03-15 20:32:5575object has none (use -f to overwrite existing notes to the
76second object). This subcommand is equivalent to:
77`git notes add [-f] -C $(git notes list <from-object>) <to-object>`
Junio C Hamano31667362010-03-25 00:38:5378+
Junio C Hamanob76a6862012-05-02 22:02:4679In `--stdin` mode, take lines in the format
Junio C Hamano31667362010-03-25 00:38:5380+
81----------
82<from-object> SP <to-object> [ SP <rest> ] LF
83----------
84+
85on standard input, and copy the notes from each <from-object> to its
86corresponding <to-object>. (The optional `<rest>` is ignored so that
87the command can read the input given to the `post-rewrite` hook.)
Junio C Hamanoea90ab32010-03-15 20:32:5588
89append::
Junio C Hamano85a51222023-07-06 19:49:5890Append new message(s) given by `-m` or `-F` options to an
91existing note, or add them as a new note if one does not
92exist, for the object (defaults to HEAD). When appending to
93an existing note, a blank line is added before each new
94message as an inter-paragraph separator. The separator can
95be customized with the `--separator` option.
Junio C Hamanoea90ab32010-03-15 20:32:5596
Junio C Hamano3b70d3c2009-11-21 17:37:3797edit::
Junio C Hamanoea90ab32010-03-15 20:32:5598Edit the notes for a given object (defaults to HEAD).
Junio C Hamano3b70d3c2009-11-21 17:37:3799
100show::
Junio C Hamanoea90ab32010-03-15 20:32:55101Show the notes for a given object (defaults to HEAD).
Junio C Hamano3b70d3c2009-11-21 17:37:37102
Junio C Hamano788eeba2010-12-08 22:50:43103merge::
104Merge the given notes ref into the current notes ref.
105This will try to merge the changes made by the given
106notes ref (called "remote") since the merge-base (if
107any) into the current notes ref (called "local").
108+
109If conflicts arise and a strategy for automatically resolving
Junio C Hamano3891e252015-08-31 23:06:13110conflicting notes (see the "NOTES MERGE STRATEGIES" section) is not given,
Junio C Hamano788eeba2010-12-08 22:50:43111the "manual" resolver is used. This resolver checks out the
112conflicting notes in a special worktree (`.git/NOTES_MERGE_WORKTREE`),
113and instructs the user to manually resolve the conflicts there.
114When done, the user can either finalize the merge with
115'git notes merge --commit', or abort the merge with
116'git notes merge --abort'.
117
Junio C Hamanoea90ab32010-03-15 20:32:55118remove::
Junio C Hamano084228c2011-05-30 08:13:52119Remove the notes for given objects (defaults to HEAD). When
120giving zero or one object from the command line, this is
121equivalent to specifying an empty note message to
Junio C Hamanoea90ab32010-03-15 20:32:55122the `edit` subcommand.
123
124prune::
125Remove all notes for non-existing/unreachable objects.
Junio C Hamano3b70d3c2009-11-21 17:37:37126
Junio C Hamano788eeba2010-12-08 22:50:43127get-ref::
128Print the current notes ref. This provides an easy way to
129retrieve the current notes ref (e.g. from scripts).
130
Junio C Hamano3b70d3c2009-11-21 17:37:37131OPTIONS
132-------
Junio C Hamanoea90ab32010-03-15 20:32:55133-f::
134--force::
135When adding notes to an object that already has notes,
136overwrite the existing notes (instead of aborting).
137
Junio C Hamano3b70d3c2009-11-21 17:37:37138-m <msg>::
Junio C Hamanoea90ab32010-03-15 20:32:55139--message=<msg>::
Junio C Hamano3b70d3c2009-11-21 17:37:37140Use the given note message (instead of prompting).
Junio C Hamanoea90ab32010-03-15 20:32:55141If multiple `-m` options are given, their values
142are concatenated as separate paragraphs.
Junio C Hamanoa574a092010-06-13 19:57:10143Lines starting with `#` and empty lines other than a
Junio C Hamano6018d902023-08-18 00:20:22144single line between paragraphs will be stripped out.
145If you wish to keep them verbatim, use `--no-stripspace`.
Junio C Hamano3b70d3c2009-11-21 17:37:37146
147-F <file>::
Junio C Hamanoea90ab32010-03-15 20:32:55148--file=<file>::
Junio C Hamano3b70d3c2009-11-21 17:37:37149Take the note message from the given file. Use '-' to
150read the note message from the standard input.
Junio C Hamanoa574a092010-06-13 19:57:10151Lines starting with `#` and empty lines other than a
Junio C Hamano6018d902023-08-18 00:20:22152single line between paragraphs will be stripped out.
153If you wish to keep them verbatim, use `--no-stripspace`.
Junio C Hamano3b70d3c2009-11-21 17:37:37154
Junio C Hamanoea90ab32010-03-15 20:32:55155-C <object>::
156--reuse-message=<object>::
Junio C Hamano6b7d2152019-04-16 12:51:15157Take the given blob object (for example, another note) as the
Junio C Hamano7bd050f2011-09-22 06:32:22158note message. (Use `git notes copy <object>` instead to
Junio C Hamano85a51222023-07-06 19:49:58159copy notes between objects.). By default, message will be
160copied verbatim, but if you wish to strip out the lines
161starting with `#` and empty lines other than a single line
162between paragraphs, use with`--stripspace` option.
Junio C Hamanoea90ab32010-03-15 20:32:55163
164-c <object>::
165--reedit-message=<object>::
Junio C Hamano92d80372016-07-13 22:00:05166Like '-C', but with `-c` the editor is invoked, so that
Junio C Hamanoea90ab32010-03-15 20:32:55167the user can further edit the note message.
Junio C Hamano3b70d3c2009-11-21 17:37:37168
Junio C Hamanofad84122014-12-05 23:38:06169--allow-empty::
170Allow an empty note object to be stored. The default behavior is
171to automatically remove empty notes.
172
Junio C Hamano85a51222023-07-06 19:49:58173--[no-]separator, --separator=<paragraph-break>::
174Specify a string used as a custom inter-paragraph separator
175(a newline is added at the end as needed). If `--no-separator`, no
176separators will be added between paragraphs. Defaults to a blank
177line.
178
179--[no-]stripspace::
180Strip leading and trailing whitespace from the note message.
181Also strip out empty lines other than a single line between
Junio C Hamano6018d902023-08-18 00:20:22182paragraphs. Lines starting with `#` will be stripped out
183in non-editor cases like `-m`, `-F` and `-C`, but not in
184editor case like `git notes edit`, `-c`, etc.
Junio C Hamano85a51222023-07-06 19:49:58185
Junio C Hamano31667362010-03-25 00:38:53186--ref <ref>::
Junio C Hamanoa574a092010-06-13 19:57:10187Manipulate the notes tree in <ref>. This overrides
Junio C Hamano042f2142016-06-27 18:05:05188`GIT_NOTES_REF` and the "core.notesRef" configuration. The ref
Junio C Hamano1f7c4a52015-10-14 22:15:51189specifies the full refname when it begins with `refs/notes/`; when it
190begins with `notes/`, `refs/` and otherwise `refs/notes/` is prefixed
191to form a full name of the ref.
Junio C Hamano31667362010-03-25 00:38:53192
Junio C Hamano084228c2011-05-30 08:13:52193--ignore-missing::
194Do not consider it an error to request removing notes from an
195object that does not have notes attached to it.
196
197--stdin::
Junio C Hamanod4bbec02017-09-25 07:24:53198Also read the object names to remove notes from the standard
Junio C Hamano084228c2011-05-30 08:13:52199input (there is no reason you cannot combine this with object
200names from the command line).
201
Junio C Hamanoa574a092010-06-13 19:57:10202-n::
Junio C Hamanoe85e36f2010-08-10 05:30:14203--dry-run::
Junio C Hamanoa574a092010-06-13 19:57:10204Do not remove anything; just report the object names whose notes
205would be removed.
Junio C Hamano31667362010-03-25 00:38:53206
Junio C Hamano788eeba2010-12-08 22:50:43207-s <strategy>::
208--strategy=<strategy>::
209When merging notes, resolve notes conflicts using the given
210strategy. The following strategies are recognized: "manual"
211(default), "ours", "theirs", "union" and "cat_sort_uniq".
Junio C Hamano3891e252015-08-31 23:06:13212This option overrides the "notes.mergeStrategy" configuration setting.
Junio C Hamano788eeba2010-12-08 22:50:43213See the "NOTES MERGE STRATEGIES" section below for more
214information on each notes merge strategy.
215
216--commit::
217Finalize an in-progress 'git notes merge'. Use this option
218when you have resolved the conflicts that 'git notes merge'
219stored in .git/NOTES_MERGE_WORKTREE. This amends the partial
220merge commit created by 'git notes merge' (stored in
221.git/NOTES_MERGE_PARTIAL) by adding the notes in
222.git/NOTES_MERGE_WORKTREE. The notes ref stored in the
223.git/NOTES_MERGE_REF symref is updated to the resulting commit.
224
225--abort::
Junio C Hamanoea1ac8d2018-07-18 20:16:48226Abort/reset an in-progress 'git notes merge', i.e. a notes merge
Junio C Hamano788eeba2010-12-08 22:50:43227with conflicts. This simply removes all files related to the
228notes merge.
229
230-q::
231--quiet::
232When merging notes, operate quietly.
233
Junio C Hamanoa574a092010-06-13 19:57:10234-v::
Junio C Hamanoe85e36f2010-08-10 05:30:14235--verbose::
Junio C Hamano788eeba2010-12-08 22:50:43236When merging notes, be more verbose.
237When pruning notes, report all object names whose notes are
238removed.
Junio C Hamanoa574a092010-06-13 19:57:10239
240
241DISCUSSION
242----------
243
244Commit notes are blobs containing extra information about an object
245(usually information to supplement a commit's message). These blobs
246are taken from notes refs. A notes ref is usually a branch which
247contains "files" whose paths are the object names for the objects
248they describe, with some directory separators included for performance
249reasons footnote:[Permitted pathnames have the form
Junio C Hamanoc9dd6422020-08-10 23:32:55250'bf'`/`'fe'`/`'30'`/`'...'`/`'680d5a...': a sequence of directory
Junio C Hamanoa574a092010-06-13 19:57:10251names of two hexadecimal digits each followed by a filename with the
252rest of the object ID.].
Junio C Hamano31667362010-03-25 00:38:53253
254Every notes change creates a new commit at the specified notes ref.
255You can therefore inspect the history of the notes by invoking, e.g.,
Junio C Hamanoa574a092010-06-13 19:57:10256`git log -p notes/commits`. Currently the commit message only records
257which operation triggered the update, and the commit authorship is
258determined according to the usual rules (see linkgit:git-commit[1]).
259These details may change in the future.
Junio C Hamano31667362010-03-25 00:38:53260
Junio C Hamanoa574a092010-06-13 19:57:10261It is also permitted for a notes ref to point directly to a tree
262object, in which case the history of the notes can be read with
263`git log -p -g <refname>`.
264
265
Junio C Hamano788eeba2010-12-08 22:50:43266NOTES MERGE STRATEGIES
267----------------------
268
269The default notes merge strategy is "manual", which checks out
270conflicting notes in a special work tree for resolving notes conflicts
271(`.git/NOTES_MERGE_WORKTREE`), and instructs the user to resolve the
272conflicts in that work tree.
273When done, the user can either finalize the merge with
274'git notes merge --commit', or abort the merge with
275'git notes merge --abort'.
276
Junio C Hamano3891e252015-08-31 23:06:13277Users may select an automated merge strategy from among the following using
278either -s/--strategy option or configuring notes.mergeStrategy accordingly:
279
Junio C Hamano788eeba2010-12-08 22:50:43280"ours" automatically resolves conflicting notes in favor of the local
281version (i.e. the current notes ref).
282
283"theirs" automatically resolves notes conflicts in favor of the remote
284version (i.e. the given notes ref being merged into the current notes
285ref).
286
287"union" automatically resolves notes conflicts by concatenating the
288local and remote versions.
289
290"cat_sort_uniq" is similar to "union", but in addition to concatenating
291the local and remote versions, this strategy also sorts the resulting
292lines, and removes duplicate lines from the result. This is equivalent
293to applying the "cat | sort | uniq" shell pipeline to the local and
294remote versions. This strategy is useful if the notes follow a line-based
295format where one wants to avoid duplicated lines in the merge result.
296Note that if either the local or remote version contain duplicate lines
297prior to the merge, these will also be removed by this notes merge
298strategy.
299
300
Junio C Hamanoa574a092010-06-13 19:57:10301EXAMPLES
302--------
303
304You can use notes to add annotations with information that was not
305available at the time a commit was written.
306
307------------
308$ git notes add -m 'Tested-by: Johannes Sixt <j6t@kdbg.org>' 72a144e2
309$ git show -s 72a144e
310[...]
311 Signed-off-by: Junio C Hamano <gitster@pobox.com>
312
313Notes:
314 Tested-by: Johannes Sixt <j6t@kdbg.org>
315------------
316
317In principle, a note is a regular Git blob, and any kind of
318(non-)format is accepted. You can binary-safely create notes from
319arbitrary files using 'git hash-object':
320
321------------
322$ cc *.c
323$ blob=$(git hash-object -w a.out)
Junio C Hamanofad84122014-12-05 23:38:06324$ git notes --ref=built add --allow-empty -C "$blob" HEAD
Junio C Hamanoa574a092010-06-13 19:57:10325------------
326
Junio C Hamano7bd050f2011-09-22 06:32:22327(You cannot simply use `git notes --ref=built add -F a.out HEAD`
328because that is not binary-safe.)
Junio C Hamanoa574a092010-06-13 19:57:10329Of course, it doesn't make much sense to display non-text-format notes
330with 'git log', so if you use such notes, you'll probably need to write
331some special-purpose tools to do something useful with them.
332
333
Junio C Hamanoba8baee2022-09-14 20:25:23334[[CONFIGURATION]]
Junio C Hamanoa574a092010-06-13 19:57:10335CONFIGURATION
336-------------
337
338core.notesRef::
339Notes ref to read and manipulate instead of
340`refs/notes/commits`. Must be an unabbreviated ref name.
341This setting can be overridden through the environment and
342command line.
343
Junio C Hamanoba8baee2022-09-14 20:25:23344include::includes/cmd-config-section-rest.txt[]
Junio C Hamano3891e252015-08-31 23:06:13345
Junio C Hamanoba8baee2022-09-14 20:25:23346include::config/notes.txt[]
Junio C Hamanoa574a092010-06-13 19:57:10347
348
349ENVIRONMENT
350-----------
351
Junio C Hamano042f2142016-06-27 18:05:05352`GIT_NOTES_REF`::
Junio C Hamanoa574a092010-06-13 19:57:10353Which ref to manipulate notes from, instead of `refs/notes/commits`.
354This overrides the `core.notesRef` setting.
355
Junio C Hamano042f2142016-06-27 18:05:05356`GIT_NOTES_DISPLAY_REF`::
Junio C Hamanoa574a092010-06-13 19:57:10357Colon-delimited list of refs or globs indicating which refs,
358in addition to the default from `core.notesRef` or
Junio C Hamano042f2142016-06-27 18:05:05359`GIT_NOTES_REF`, to read notes from when showing commit
Junio C Hamanoa574a092010-06-13 19:57:10360messages.
361This overrides the `notes.displayRef` setting.
362+
363A warning will be issued for refs that do not exist, but a glob that
364does not match any refs is silently ignored.
365
Junio C Hamano042f2142016-06-27 18:05:05366`GIT_NOTES_REWRITE_MODE`::
Junio C Hamanoa574a092010-06-13 19:57:10367When copying notes during a rewrite, what to do if the target
368commit already has a note.
Junio C Hamano3891e252015-08-31 23:06:13369Must be one of `overwrite`, `concatenate`, `cat_sort_uniq`, or `ignore`.
Junio C Hamanoa574a092010-06-13 19:57:10370This overrides the `core.rewriteMode` setting.
371
Junio C Hamano042f2142016-06-27 18:05:05372`GIT_NOTES_REWRITE_REF`::
Junio C Hamanoa574a092010-06-13 19:57:10373When rewriting commits, which notes to copy from the original
374to the rewritten commit. Must be a colon-delimited list of
375refs or globs.
376+
377If not set in the environment, the list of notes to copy depends
378on the `notes.rewrite.<command>` and `notes.rewriteRef` settings.
Junio C Hamano31667362010-03-25 00:38:53379
Junio C Hamano3b70d3c2009-11-21 17:37:37380GIT
381---
Junio C Hamano198b1f12016-05-17 22:27:24382Part of the linkgit:git[1] suite