blob: 84022f99d76d13b1fbb6008fe747e2c206333c6e [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 Hamanof4e4f532024-11-02 05:48:1112'git notes' add [-f] [--allow-empty] [--[no-]separator | --separator=<paragraph-break>] [--[no-]stripspace] [-F <file> | -m <msg> | (-c | -C) <object>] [-e] [<object>]
Junio C Hamano8ac8a3d2019-11-11 04:33:4613'git notes' copy [-f] ( --stdin | <from-object> [<to-object>] )
Junio C Hamanof4e4f532024-11-02 05:48:1114'git notes' append [--allow-empty] [--[no-]separator | --separator=<paragraph-break>] [--[no-]stripspace] [-F <file> | -m <msg> | (-c | -C) <object>] [-e] [<object>]
Junio C Hamano85a51222023-07-06 19:49:5815'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
Junio C Hamano6546a502024-02-08 23:48:3659annotate (in the format "<note-object> <annotated-object>").
Junio C Hamanoea90ab32010-03-15 20:32:5560This 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`
Junio C Hamanof4e4f532024-11-02 05:48:1170option to insert other delimiters. You can use `-e` to edit and
71fine-tune the message(s) supplied from `-m` and `-F` options
72interactively (using an editor) before adding the note.
Junio C Hamanoea90ab32010-03-15 20:32:5573
74copy::
Junio C Hamano8ac8a3d2019-11-11 04:33:4675Copy the notes for the first object onto the second object (defaults to
76HEAD). Abort if the second object already has notes, or if the first
Junio C Hamanoea90ab32010-03-15 20:32:5577object has none (use -f to overwrite existing notes to the
78second object). This subcommand is equivalent to:
79`git notes add [-f] -C $(git notes list <from-object>) <to-object>`
Junio C Hamano31667362010-03-25 00:38:5380+
Junio C Hamanob76a6862012-05-02 22:02:4681In `--stdin` mode, take lines in the format
Junio C Hamano31667362010-03-25 00:38:5382+
83----------
84<from-object> SP <to-object> [ SP <rest> ] LF
85----------
86+
87on standard input, and copy the notes from each <from-object> to its
88corresponding <to-object>. (The optional `<rest>` is ignored so that
89the command can read the input given to the `post-rewrite` hook.)
Junio C Hamanoea90ab32010-03-15 20:32:5590
91append::
Junio C Hamano85a51222023-07-06 19:49:5892Append new message(s) given by `-m` or `-F` options to an
93existing note, or add them as a new note if one does not
94exist, for the object (defaults to HEAD). When appending to
95an existing note, a blank line is added before each new
96message as an inter-paragraph separator. The separator can
97be customized with the `--separator` option.
Junio C Hamanof4e4f532024-11-02 05:48:1198Edit the notes to be appended given by `-m` and `-F` options with
99`-e` interactively (using an editor) before appending the note.
Junio C Hamanoea90ab32010-03-15 20:32:55100
Junio C Hamano3b70d3c2009-11-21 17:37:37101edit::
Junio C Hamanoea90ab32010-03-15 20:32:55102Edit the notes for a given object (defaults to HEAD).
Junio C Hamano3b70d3c2009-11-21 17:37:37103
104show::
Junio C Hamanoea90ab32010-03-15 20:32:55105Show the notes for a given object (defaults to HEAD).
Junio C Hamano3b70d3c2009-11-21 17:37:37106
Junio C Hamano788eeba2010-12-08 22:50:43107merge::
108Merge the given notes ref into the current notes ref.
109This will try to merge the changes made by the given
110notes ref (called "remote") since the merge-base (if
111any) into the current notes ref (called "local").
112+
113If conflicts arise and a strategy for automatically resolving
Junio C Hamano3891e252015-08-31 23:06:13114conflicting notes (see the "NOTES MERGE STRATEGIES" section) is not given,
Junio C Hamano788eeba2010-12-08 22:50:43115the "manual" resolver is used. This resolver checks out the
116conflicting notes in a special worktree (`.git/NOTES_MERGE_WORKTREE`),
117and instructs the user to manually resolve the conflicts there.
118When done, the user can either finalize the merge with
119'git notes merge --commit', or abort the merge with
120'git notes merge --abort'.
121
Junio C Hamanoea90ab32010-03-15 20:32:55122remove::
Junio C Hamano084228c2011-05-30 08:13:52123Remove the notes for given objects (defaults to HEAD). When
124giving zero or one object from the command line, this is
125equivalent to specifying an empty note message to
Junio C Hamanoea90ab32010-03-15 20:32:55126the `edit` subcommand.
127
128prune::
129Remove all notes for non-existing/unreachable objects.
Junio C Hamano3b70d3c2009-11-21 17:37:37130
Junio C Hamano788eeba2010-12-08 22:50:43131get-ref::
132Print the current notes ref. This provides an easy way to
133retrieve the current notes ref (e.g. from scripts).
134
Junio C Hamano3b70d3c2009-11-21 17:37:37135OPTIONS
136-------
Junio C Hamanoea90ab32010-03-15 20:32:55137-f::
138--force::
139When adding notes to an object that already has notes,
140overwrite the existing notes (instead of aborting).
141
Junio C Hamano3b70d3c2009-11-21 17:37:37142-m <msg>::
Junio C Hamanoea90ab32010-03-15 20:32:55143--message=<msg>::
Junio C Hamano3b70d3c2009-11-21 17:37:37144Use the given note message (instead of prompting).
Junio C Hamanoea90ab32010-03-15 20:32:55145If multiple `-m` options are given, their values
146are concatenated as separate paragraphs.
Junio C Hamanoa574a092010-06-13 19:57:10147Lines starting with `#` and empty lines other than a
Junio C Hamano6018d902023-08-18 00:20:22148single line between paragraphs will be stripped out.
149If you wish to keep them verbatim, use `--no-stripspace`.
Junio C Hamano3b70d3c2009-11-21 17:37:37150
151-F <file>::
Junio C Hamanoea90ab32010-03-15 20:32:55152--file=<file>::
Junio C Hamano3b70d3c2009-11-21 17:37:37153Take the note message from the given file. Use '-' to
154read the note message from the standard input.
Junio C Hamanoa574a092010-06-13 19:57:10155Lines starting with `#` and empty lines other than a
Junio C Hamano6018d902023-08-18 00:20:22156single line between paragraphs will be stripped out.
157If you wish to keep them verbatim, use `--no-stripspace`.
Junio C Hamano3b70d3c2009-11-21 17:37:37158
Junio C Hamanoea90ab32010-03-15 20:32:55159-C <object>::
160--reuse-message=<object>::
Junio C Hamano6b7d2152019-04-16 12:51:15161Take the given blob object (for example, another note) as the
Junio C Hamano7bd050f2011-09-22 06:32:22162note message. (Use `git notes copy <object>` instead to
Junio C Hamano85a51222023-07-06 19:49:58163copy notes between objects.). By default, message will be
164copied verbatim, but if you wish to strip out the lines
165starting with `#` and empty lines other than a single line
166between paragraphs, use with`--stripspace` option.
Junio C Hamanoea90ab32010-03-15 20:32:55167
168-c <object>::
169--reedit-message=<object>::
Junio C Hamano92d80372016-07-13 22:00:05170Like '-C', but with `-c` the editor is invoked, so that
Junio C Hamanoea90ab32010-03-15 20:32:55171the user can further edit the note message.
Junio C Hamano3b70d3c2009-11-21 17:37:37172
Junio C Hamanofad84122014-12-05 23:38:06173--allow-empty::
174Allow an empty note object to be stored. The default behavior is
175to automatically remove empty notes.
176
Junio C Hamano85a51222023-07-06 19:49:58177--[no-]separator, --separator=<paragraph-break>::
178Specify a string used as a custom inter-paragraph separator
179(a newline is added at the end as needed). If `--no-separator`, no
180separators will be added between paragraphs. Defaults to a blank
181line.
182
183--[no-]stripspace::
184Strip leading and trailing whitespace from the note message.
185Also strip out empty lines other than a single line between
Junio C Hamano6018d902023-08-18 00:20:22186paragraphs. Lines starting with `#` will be stripped out
187in non-editor cases like `-m`, `-F` and `-C`, but not in
188editor case like `git notes edit`, `-c`, etc.
Junio C Hamano85a51222023-07-06 19:49:58189
Junio C Hamano31667362010-03-25 00:38:53190--ref <ref>::
Junio C Hamanoa574a092010-06-13 19:57:10191Manipulate the notes tree in <ref>. This overrides
Junio C Hamano042f2142016-06-27 18:05:05192`GIT_NOTES_REF` and the "core.notesRef" configuration. The ref
Junio C Hamano1f7c4a52015-10-14 22:15:51193specifies the full refname when it begins with `refs/notes/`; when it
194begins with `notes/`, `refs/` and otherwise `refs/notes/` is prefixed
195to form a full name of the ref.
Junio C Hamano31667362010-03-25 00:38:53196
Junio C Hamano084228c2011-05-30 08:13:52197--ignore-missing::
198Do not consider it an error to request removing notes from an
199object that does not have notes attached to it.
200
201--stdin::
Junio C Hamanod4bbec02017-09-25 07:24:53202Also read the object names to remove notes from the standard
Junio C Hamano084228c2011-05-30 08:13:52203input (there is no reason you cannot combine this with object
204names from the command line).
205
Junio C Hamanoa574a092010-06-13 19:57:10206-n::
Junio C Hamanoe85e36f2010-08-10 05:30:14207--dry-run::
Junio C Hamanoa574a092010-06-13 19:57:10208Do not remove anything; just report the object names whose notes
209would be removed.
Junio C Hamano31667362010-03-25 00:38:53210
Junio C Hamano788eeba2010-12-08 22:50:43211-s <strategy>::
212--strategy=<strategy>::
213When merging notes, resolve notes conflicts using the given
214strategy. The following strategies are recognized: "manual"
215(default), "ours", "theirs", "union" and "cat_sort_uniq".
Junio C Hamano3891e252015-08-31 23:06:13216This option overrides the "notes.mergeStrategy" configuration setting.
Junio C Hamano788eeba2010-12-08 22:50:43217See the "NOTES MERGE STRATEGIES" section below for more
218information on each notes merge strategy.
219
220--commit::
221Finalize an in-progress 'git notes merge'. Use this option
222when you have resolved the conflicts that 'git notes merge'
223stored in .git/NOTES_MERGE_WORKTREE. This amends the partial
224merge commit created by 'git notes merge' (stored in
225.git/NOTES_MERGE_PARTIAL) by adding the notes in
226.git/NOTES_MERGE_WORKTREE. The notes ref stored in the
227.git/NOTES_MERGE_REF symref is updated to the resulting commit.
228
229--abort::
Junio C Hamanoea1ac8d2018-07-18 20:16:48230Abort/reset an in-progress 'git notes merge', i.e. a notes merge
Junio C Hamano788eeba2010-12-08 22:50:43231with conflicts. This simply removes all files related to the
232notes merge.
233
234-q::
235--quiet::
236When merging notes, operate quietly.
237
Junio C Hamanoa574a092010-06-13 19:57:10238-v::
Junio C Hamanoe85e36f2010-08-10 05:30:14239--verbose::
Junio C Hamano788eeba2010-12-08 22:50:43240When merging notes, be more verbose.
241When pruning notes, report all object names whose notes are
242removed.
Junio C Hamanoa574a092010-06-13 19:57:10243
244
245DISCUSSION
246----------
247
248Commit notes are blobs containing extra information about an object
249(usually information to supplement a commit's message). These blobs
250are taken from notes refs. A notes ref is usually a branch which
251contains "files" whose paths are the object names for the objects
252they describe, with some directory separators included for performance
253reasons footnote:[Permitted pathnames have the form
Junio C Hamanoc9dd6422020-08-10 23:32:55254'bf'`/`'fe'`/`'30'`/`'...'`/`'680d5a...': a sequence of directory
Junio C Hamanoa574a092010-06-13 19:57:10255names of two hexadecimal digits each followed by a filename with the
256rest of the object ID.].
Junio C Hamano31667362010-03-25 00:38:53257
258Every notes change creates a new commit at the specified notes ref.
259You can therefore inspect the history of the notes by invoking, e.g.,
Junio C Hamanoa574a092010-06-13 19:57:10260`git log -p notes/commits`. Currently the commit message only records
261which operation triggered the update, and the commit authorship is
262determined according to the usual rules (see linkgit:git-commit[1]).
263These details may change in the future.
Junio C Hamano31667362010-03-25 00:38:53264
Junio C Hamanoa574a092010-06-13 19:57:10265It is also permitted for a notes ref to point directly to a tree
266object, in which case the history of the notes can be read with
267`git log -p -g <refname>`.
268
269
Junio C Hamano788eeba2010-12-08 22:50:43270NOTES MERGE STRATEGIES
271----------------------
272
273The default notes merge strategy is "manual", which checks out
274conflicting notes in a special work tree for resolving notes conflicts
275(`.git/NOTES_MERGE_WORKTREE`), and instructs the user to resolve the
276conflicts in that work tree.
277When done, the user can either finalize the merge with
278'git notes merge --commit', or abort the merge with
279'git notes merge --abort'.
280
Junio C Hamano3891e252015-08-31 23:06:13281Users may select an automated merge strategy from among the following using
282either -s/--strategy option or configuring notes.mergeStrategy accordingly:
283
Junio C Hamano788eeba2010-12-08 22:50:43284"ours" automatically resolves conflicting notes in favor of the local
285version (i.e. the current notes ref).
286
287"theirs" automatically resolves notes conflicts in favor of the remote
288version (i.e. the given notes ref being merged into the current notes
289ref).
290
291"union" automatically resolves notes conflicts by concatenating the
292local and remote versions.
293
294"cat_sort_uniq" is similar to "union", but in addition to concatenating
295the local and remote versions, this strategy also sorts the resulting
296lines, and removes duplicate lines from the result. This is equivalent
297to applying the "cat | sort | uniq" shell pipeline to the local and
298remote versions. This strategy is useful if the notes follow a line-based
299format where one wants to avoid duplicated lines in the merge result.
300Note that if either the local or remote version contain duplicate lines
301prior to the merge, these will also be removed by this notes merge
302strategy.
303
304
Junio C Hamanoa574a092010-06-13 19:57:10305EXAMPLES
306--------
307
308You can use notes to add annotations with information that was not
309available at the time a commit was written.
310
311------------
312$ git notes add -m 'Tested-by: Johannes Sixt <j6t@kdbg.org>' 72a144e2
313$ git show -s 72a144e
314[...]
315 Signed-off-by: Junio C Hamano <gitster@pobox.com>
316
317Notes:
318 Tested-by: Johannes Sixt <j6t@kdbg.org>
319------------
320
321In principle, a note is a regular Git blob, and any kind of
322(non-)format is accepted. You can binary-safely create notes from
323arbitrary files using 'git hash-object':
324
325------------
326$ cc *.c
327$ blob=$(git hash-object -w a.out)
Junio C Hamanofad84122014-12-05 23:38:06328$ git notes --ref=built add --allow-empty -C "$blob" HEAD
Junio C Hamanoa574a092010-06-13 19:57:10329------------
330
Junio C Hamano7bd050f2011-09-22 06:32:22331(You cannot simply use `git notes --ref=built add -F a.out HEAD`
332because that is not binary-safe.)
Junio C Hamanoa574a092010-06-13 19:57:10333Of course, it doesn't make much sense to display non-text-format notes
334with 'git log', so if you use such notes, you'll probably need to write
335some special-purpose tools to do something useful with them.
336
337
Junio C Hamanoba8baee2022-09-14 20:25:23338[[CONFIGURATION]]
Junio C Hamanoa574a092010-06-13 19:57:10339CONFIGURATION
340-------------
341
342core.notesRef::
343Notes ref to read and manipulate instead of
344`refs/notes/commits`. Must be an unabbreviated ref name.
345This setting can be overridden through the environment and
346command line.
347
Junio C Hamanoba8baee2022-09-14 20:25:23348include::includes/cmd-config-section-rest.txt[]
Junio C Hamano3891e252015-08-31 23:06:13349
Junio C Hamanoba8baee2022-09-14 20:25:23350include::config/notes.txt[]
Junio C Hamanoa574a092010-06-13 19:57:10351
352
353ENVIRONMENT
354-----------
355
Junio C Hamano042f2142016-06-27 18:05:05356`GIT_NOTES_REF`::
Junio C Hamanoa574a092010-06-13 19:57:10357Which ref to manipulate notes from, instead of `refs/notes/commits`.
358This overrides the `core.notesRef` setting.
359
Junio C Hamano042f2142016-06-27 18:05:05360`GIT_NOTES_DISPLAY_REF`::
Junio C Hamanoa574a092010-06-13 19:57:10361Colon-delimited list of refs or globs indicating which refs,
362in addition to the default from `core.notesRef` or
Junio C Hamano042f2142016-06-27 18:05:05363`GIT_NOTES_REF`, to read notes from when showing commit
Junio C Hamanoa574a092010-06-13 19:57:10364messages.
365This overrides the `notes.displayRef` setting.
366+
367A warning will be issued for refs that do not exist, but a glob that
368does not match any refs is silently ignored.
369
Junio C Hamano042f2142016-06-27 18:05:05370`GIT_NOTES_REWRITE_MODE`::
Junio C Hamanoa574a092010-06-13 19:57:10371When copying notes during a rewrite, what to do if the target
372commit already has a note.
Junio C Hamano3891e252015-08-31 23:06:13373Must be one of `overwrite`, `concatenate`, `cat_sort_uniq`, or `ignore`.
Junio C Hamanoa574a092010-06-13 19:57:10374This overrides the `core.rewriteMode` setting.
375
Junio C Hamano042f2142016-06-27 18:05:05376`GIT_NOTES_REWRITE_REF`::
Junio C Hamanoa574a092010-06-13 19:57:10377When rewriting commits, which notes to copy from the original
378to the rewritten commit. Must be a colon-delimited list of
379refs or globs.
380+
381If not set in the environment, the list of notes to copy depends
382on the `notes.rewrite.<command>` and `notes.rewriteRef` settings.
Junio C Hamano31667362010-03-25 00:38:53383
Junio C Hamano3b70d3c2009-11-21 17:37:37384GIT
385---
Junio C Hamano198b1f12016-05-17 22:27:24386Part of the linkgit:git[1] suite