blob: 46ef0466beed0b297f986a652e4da1efedf2681c [file] [log] [blame]
Johannes Schindelin65d9fb42009-10-09 12:21:58 +02001git-notes(1)
2============
3
4NAME
5----
Jonathan Nieder1a3eb9a2010-05-08 22:37:21 -05006git-notes - Add or inspect object notes
Johannes Schindelin65d9fb42009-10-09 12:21:58 +02007
8SYNOPSIS
9--------
10[verse]
Johan Herlande3974212010-02-13 22:28:30 +010011'git notes' [list [<object>]]
Johan Herland0691cff2010-02-13 22:28:36 +010012'git notes' add [-f] [-F <file> | -m <msg> | (-c | -C) <object>] [<object>]
Thomas Rast160baa02010-03-12 18:04:31 +010013'git notes' copy [-f] ( --stdin | <from-object> <to-object> )
Johan Herland0691cff2010-02-13 22:28:36 +010014'git notes' append [-F <file> | -m <msg> | (-c | -C) <object>] [<object>]
Johan Herlandaaec9bc2010-02-13 22:28:34 +010015'git notes' edit [<object>]
Johan Herlande3974212010-02-13 22:28:30 +010016'git notes' show [<object>]
Johan Herland00f03062010-11-09 22:49:50 +010017'git notes' merge [-v | -q] [-s <strategy> ] <notes_ref>
Johan Herland6abb3652010-11-09 22:49:52 +010018'git notes' merge --commit [-v | -q]
19'git notes' merge --abort [-v | -q]
Junio C Hamano46538012011-05-18 16:44:30 -070020'git notes' remove [--ignore-missing] [--stdin] [<object>...]
Michael J Grubera9f2adf2010-05-14 23:42:07 +020021'git notes' prune [-n | -v]
Johan Herland618cd752010-11-09 22:49:57 +010022'git notes' get-ref
Johan Herlande3974212010-02-13 22:28:30 +010023
Johannes Schindelin65d9fb42009-10-09 12:21:58 +020024
25DESCRIPTION
26-----------
Jonathan Nieder1a3eb9a2010-05-08 22:37:21 -050027Adds, removes, or reads notes attached to objects, without touching
28the objects themselves.
Johannes Schindelin65d9fb42009-10-09 12:21:58 +020029
Jonathan Nieder00979712010-05-08 22:23:58 -050030By 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
Jonathan Nieder1a3eb9a2010-05-08 22:37:21 -050035A 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
Johan Herland7d541172010-02-13 22:28:29 +010038message stored in the commit object, the notes are indented like the
Thomas Rast894a9d32010-03-12 18:04:26 +010039message, after an unindented line saying "Notes (<refname>):" (or
Jonathan Nieder9eb3f812010-05-08 22:19:35 -050040"Notes:" for `refs/notes/commits`).
Johan Herland7d541172010-02-13 22:28:29 +010041
Philip Oakleye39b3072012-10-21 22:34:09 +010042Notes 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
Jonathan Nieder66c4c322010-05-08 22:32:24 -050046To change which notes are shown by 'git log', see the
47"notes.displayRef" configuration in linkgit:git-log[1].
Johannes Schindelin65d9fb42009-10-09 12:21:58 +020048
Jonathan Niederc5ce1832010-05-08 22:33:28 -050049See the "notes.rewrite.<command>" configuration for a way to carry
50notes across commands that rewrite commits.
Johannes Schindelin65d9fb42009-10-09 12:21:58 +020051
52
53SUBCOMMANDS
54-----------
55
Johan Herlande3974212010-02-13 22:28:30 +010056list::
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
Johan Herland7aa47542010-02-13 22:28:32 +010062add::
63 Add notes for a given object (defaults to HEAD). Abort if the
Johan Herland84a7e352011-03-30 02:02:55 +020064 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).
Johan Herland7aa47542010-02-13 22:28:32 +010069
Johan Herlande73bbd92010-02-13 22:28:38 +010070copy::
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
Michael J Gruber48716a22010-03-04 15:31:17 +010073 object has none (use -f to overwrite existing notes to the
Johan Herlande73bbd92010-02-13 22:28:38 +010074 second object). This subcommand is equivalent to:
75 `git notes add [-f] -C $(git notes list <from-object>) <to-object>`
Thomas Rast160baa02010-03-12 18:04:31 +010076+
Jeff King6cf378f2012-04-26 04:51:57 -040077In `--stdin` mode, take lines in the format
Thomas Rast160baa02010-03-12 18:04:31 +010078+
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.)
Johan Herlande73bbd92010-02-13 22:28:38 +010086
Johan Herland2347fae2010-02-13 22:28:33 +010087append::
88 Append to the notes of an existing object (defaults to HEAD).
89 Creates a new notes object if needed.
90
Johannes Schindelin65d9fb42009-10-09 12:21:58 +020091edit::
Johan Herland7d541172010-02-13 22:28:29 +010092 Edit the notes for a given object (defaults to HEAD).
Johannes Schindelin65d9fb42009-10-09 12:21:58 +020093
94show::
Johan Herland7d541172010-02-13 22:28:29 +010095 Show the notes for a given object (defaults to HEAD).
Johannes Schindelin65d9fb42009-10-09 12:21:58 +020096
Johan Herland00f03062010-11-09 22:49:50 +010097merge::
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 -s/--strategy option) is not given,
Johan Herland809f38c2010-11-09 22:49:51 +0100105the "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.
Johan Herland6abb3652010-11-09 22:49:52 +0100108When done, the user can either finalize the merge with
109'git notes merge --commit', or abort the merge with
110'git notes merge --abort'.
Johan Herland00f03062010-11-09 22:49:50 +0100111
Johan Herland92b33852010-02-13 22:28:25 +0100112remove::
Junio C Hamanoc3ab1a82011-05-18 15:44:37 -0700113 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
Johan Herland92b33852010-02-13 22:28:25 +0100116 the `edit` subcommand.
117
Johan Herlandd6576e12010-02-13 22:28:28 +0100118prune::
119 Remove all notes for non-existing/unreachable objects.
Johannes Schindelin65d9fb42009-10-09 12:21:58 +0200120
Johan Herland618cd752010-11-09 22:49:57 +0100121get-ref::
122 Print the current notes ref. This provides an easy way to
123 retrieve the current notes ref (e.g. from scripts).
124
Johan Herlandd9246d42009-10-09 12:22:01 +0200125OPTIONS
126-------
Johan Herland7aa47542010-02-13 22:28:32 +0100127-f::
128--force::
129 When adding notes to an object that already has notes,
130 overwrite the existing notes (instead of aborting).
131
Johan Herlandd9246d42009-10-09 12:22:01 +0200132-m <msg>::
Johan Herlandba20f152010-02-13 22:28:31 +0100133--message=<msg>::
Johan Herlandd9246d42009-10-09 12:22:01 +0200134 Use the given note message (instead of prompting).
Johan Herlandcd067d32010-02-13 22:28:20 +0100135 If multiple `-m` options are given, their values
136 are concatenated as separate paragraphs.
Jonathan Nieder8d6888e2010-05-08 22:21:34 -0500137 Lines starting with `#` and empty lines other than a
138 single line between paragraphs will be stripped out.
Johan Herlandd9246d42009-10-09 12:22:01 +0200139
140-F <file>::
Johan Herlandba20f152010-02-13 22:28:31 +0100141--file=<file>::
Johan Herlandd9246d42009-10-09 12:22:01 +0200142 Take the note message from the given file. Use '-' to
143 read the note message from the standard input.
Jonathan Nieder8d6888e2010-05-08 22:21:34 -0500144 Lines starting with `#` and empty lines other than a
145 single line between paragraphs will be stripped out.
Johan Herlandd9246d42009-10-09 12:22:01 +0200146
Johan Herland0691cff2010-02-13 22:28:36 +0100147-C <object>::
148--reuse-message=<object>::
Michael J Gruber11432bb2011-08-25 12:26:37 +0200149 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.)
Johan Herland0691cff2010-02-13 22:28:36 +0100152
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.
Johan Herlandd9246d42009-10-09 12:22:01 +0200157
Thomas Rastdcf783a2010-03-12 18:04:35 +0100158--ref <ref>::
Jonathan Nieder00979712010-05-08 22:23:58 -0500159 Manipulate the notes tree in <ref>. This overrides
160 'GIT_NOTES_REF' and the "core.notesRef" configuration. The ref
Thomas Rastdcf783a2010-03-12 18:04:35 +0100161 is taken to be in `refs/notes/` if it is not qualified.
162
Junio C Hamano2d370d22011-05-18 16:02:58 -0700163--ignore-missing::
164 Do not consider it an error to request removing notes from an
165 object that does not have notes attached to it.
166
Junio C Hamano46538012011-05-18 16:44:30 -0700167--stdin::
168 Also read the object names to remove notes from from the standard
169 input (there is no reason you cannot combine this with object
170 names from the command line).
171
Michael J Grubera9f2adf2010-05-14 23:42:07 +0200172-n::
René Scharfee93487d2010-08-06 22:28:09 +0200173--dry-run::
Michael J Grubera9f2adf2010-05-14 23:42:07 +0200174 Do not remove anything; just report the object names whose notes
175 would be removed.
176
Johan Herland00f03062010-11-09 22:49:50 +0100177-s <strategy>::
178--strategy=<strategy>::
179 When merging notes, resolve notes conflicts using the given
180 strategy. The following strategies are recognized: "manual"
Johan Herlanda6a09092010-11-15 00:57:17 +0100181 (default), "ours", "theirs", "union" and "cat_sort_uniq".
Johan Herland00f03062010-11-09 22:49:50 +0100182 See the "NOTES MERGE STRATEGIES" section below for more
183 information on each notes merge strategy.
184
Johan Herland6abb3652010-11-09 22:49:52 +0100185--commit::
186 Finalize an in-progress 'git notes merge'. Use this option
187 when you have resolved the conflicts that 'git notes merge'
188 stored in .git/NOTES_MERGE_WORKTREE. This amends the partial
189 merge commit created by 'git notes merge' (stored in
190 .git/NOTES_MERGE_PARTIAL) by adding the notes in
191 .git/NOTES_MERGE_WORKTREE. The notes ref stored in the
192 .git/NOTES_MERGE_REF symref is updated to the resulting commit.
193
194--abort::
195 Abort/reset a in-progress 'git notes merge', i.e. a notes merge
196 with conflicts. This simply removes all files related to the
197 notes merge.
198
Johan Herland00f03062010-11-09 22:49:50 +0100199-q::
200--quiet::
201 When merging notes, operate quietly.
202
Michael J Grubera9f2adf2010-05-14 23:42:07 +0200203-v::
René Scharfee93487d2010-08-06 22:28:09 +0200204--verbose::
Johan Herland00f03062010-11-09 22:49:50 +0100205 When merging notes, be more verbose.
206 When pruning notes, report all object names whose notes are
207 removed.
Michael J Grubera9f2adf2010-05-14 23:42:07 +0200208
Thomas Rast66d68192010-03-12 18:04:37 +0100209
Jonathan Nieder9eb3f812010-05-08 22:19:35 -0500210DISCUSSION
211----------
212
213Commit notes are blobs containing extra information about an object
214(usually information to supplement a commit's message). These blobs
215are taken from notes refs. A notes ref is usually a branch which
216contains "files" whose paths are the object names for the objects
217they describe, with some directory separators included for performance
218reasons footnote:[Permitted pathnames have the form
219'ab'`/`'cd'`/`'ef'`/`'...'`/`'abcdef...': a sequence of directory
220names of two hexadecimal digits each followed by a filename with the
221rest of the object ID.].
Thomas Rast66d68192010-03-12 18:04:37 +0100222
223Every notes change creates a new commit at the specified notes ref.
224You can therefore inspect the history of the notes by invoking, e.g.,
Jonathan Nieder9eb3f812010-05-08 22:19:35 -0500225`git log -p notes/commits`. Currently the commit message only records
226which operation triggered the update, and the commit authorship is
227determined according to the usual rules (see linkgit:git-commit[1]).
228These details may change in the future.
Thomas Rast66d68192010-03-12 18:04:37 +0100229
Jonathan Nieder9eb3f812010-05-08 22:19:35 -0500230It is also permitted for a notes ref to point directly to a tree
231object, in which case the history of the notes can be read with
232`git log -p -g <refname>`.
Thomas Rast66d68192010-03-12 18:04:37 +0100233
234
Johan Herland00f03062010-11-09 22:49:50 +0100235NOTES MERGE STRATEGIES
236----------------------
237
Johan Herland809f38c2010-11-09 22:49:51 +0100238The default notes merge strategy is "manual", which checks out
239conflicting notes in a special work tree for resolving notes conflicts
240(`.git/NOTES_MERGE_WORKTREE`), and instructs the user to resolve the
241conflicts in that work tree.
Johan Herland6abb3652010-11-09 22:49:52 +0100242When done, the user can either finalize the merge with
243'git notes merge --commit', or abort the merge with
244'git notes merge --abort'.
Johan Herland00f03062010-11-09 22:49:50 +0100245
246"ours" automatically resolves conflicting notes in favor of the local
247version (i.e. the current notes ref).
248
249"theirs" automatically resolves notes conflicts in favor of the remote
250version (i.e. the given notes ref being merged into the current notes
251ref).
252
253"union" automatically resolves notes conflicts by concatenating the
254local and remote versions.
255
Johan Herlanda6a09092010-11-15 00:57:17 +0100256"cat_sort_uniq" is similar to "union", but in addition to concatenating
257the local and remote versions, this strategy also sorts the resulting
258lines, and removes duplicate lines from the result. This is equivalent
259to applying the "cat | sort | uniq" shell pipeline to the local and
260remote versions. This strategy is useful if the notes follow a line-based
261format where one wants to avoid duplicated lines in the merge result.
262Note that if either the local or remote version contain duplicate lines
263prior to the merge, these will also be removed by this notes merge
264strategy.
265
Johan Herland00f03062010-11-09 22:49:50 +0100266
Jonathan Nieder8d6888e2010-05-08 22:21:34 -0500267EXAMPLES
268--------
269
270You can use notes to add annotations with information that was not
271available at the time a commit was written.
272
273------------
274$ git notes add -m 'Tested-by: Johannes Sixt <j6t@kdbg.org>' 72a144e2
275$ git show -s 72a144e
276[...]
277 Signed-off-by: Junio C Hamano <gitster@pobox.com>
278
279Notes:
280 Tested-by: Johannes Sixt <j6t@kdbg.org>
281------------
282
283In principle, a note is a regular Git blob, and any kind of
284(non-)format is accepted. You can binary-safely create notes from
285arbitrary files using 'git hash-object':
286
287------------
288$ cc *.c
289$ blob=$(git hash-object -w a.out)
290$ git notes --ref=built add -C "$blob" HEAD
291------------
292
Michael J Gruber11432bb2011-08-25 12:26:37 +0200293(You cannot simply use `git notes --ref=built add -F a.out HEAD`
294because that is not binary-safe.)
Jonathan Nieder8d6888e2010-05-08 22:21:34 -0500295Of course, it doesn't make much sense to display non-text-format notes
296with 'git log', so if you use such notes, you'll probably need to write
297some special-purpose tools to do something useful with them.
298
299
Jonathan Niedered9098f2010-05-08 22:21:59 -0500300CONFIGURATION
301-------------
302
303core.notesRef::
Jonathan Nieder00979712010-05-08 22:23:58 -0500304 Notes ref to read and manipulate instead of
305 `refs/notes/commits`. Must be an unabbreviated ref name.
306 This setting can be overridden through the environment and
307 command line.
Jonathan Niedered9098f2010-05-08 22:21:59 -0500308
309notes.displayRef::
Jonathan Nieder66c4c322010-05-08 22:32:24 -0500310 Which ref (or refs, if a glob or specified more than once), in
311 addition to the default set by `core.notesRef` or
312 'GIT_NOTES_REF', to read notes from when showing commit
313 messages with the 'git log' family of commands.
314 This setting can be overridden on the command line or by the
315 'GIT_NOTES_DISPLAY_REF' environment variable.
316 See linkgit:git-log[1].
Jonathan Niedered9098f2010-05-08 22:21:59 -0500317
318notes.rewrite.<command>::
319 When rewriting commits with <command> (currently `amend` or
Jonathan Niederc5ce1832010-05-08 22:33:28 -0500320 `rebase`), if this variable is `false`, git will not copy
321 notes from the original to the rewritten commit. Defaults to
322 `true`. See also "`notes.rewriteRef`" below.
323+
324This setting can be overridden by the 'GIT_NOTES_REWRITE_REF'
325environment variable.
Jonathan Niedered9098f2010-05-08 22:21:59 -0500326
327notes.rewriteMode::
Jonathan Niederc5ce1832010-05-08 22:33:28 -0500328 When copying notes during a rewrite, what to do if the target
329 commit already has a note. Must be one of `overwrite`,
330 `concatenate`, and `ignore`. Defaults to `concatenate`.
Jonathan Niedered9098f2010-05-08 22:21:59 -0500331+
332This setting can be overridden with the `GIT_NOTES_REWRITE_MODE`
333environment variable.
334
335notes.rewriteRef::
336 When copying notes during a rewrite, specifies the (fully
Jonathan Niederc5ce1832010-05-08 22:33:28 -0500337 qualified) ref whose notes should be copied. May be a glob,
338 in which case notes in all matching refs will be copied. You
339 may also specify this configuration several times.
Jonathan Niedered9098f2010-05-08 22:21:59 -0500340+
341Does not have a default value; you must configure this variable to
342enable note rewriting.
343+
Jonathan Niederc5ce1832010-05-08 22:33:28 -0500344Can be overridden with the 'GIT_NOTES_REWRITE_REF' environment variable.
Jonathan Niedered9098f2010-05-08 22:21:59 -0500345
Jonathan Nieder00979712010-05-08 22:23:58 -0500346
347ENVIRONMENT
348-----------
349
350'GIT_NOTES_REF'::
351 Which ref to manipulate notes from, instead of `refs/notes/commits`.
352 This overrides the `core.notesRef` setting.
353
Jonathan Nieder66c4c322010-05-08 22:32:24 -0500354'GIT_NOTES_DISPLAY_REF'::
355 Colon-delimited list of refs or globs indicating which refs,
356 in addition to the default from `core.notesRef` or
357 'GIT_NOTES_REF', to read notes from when showing commit
358 messages.
359 This overrides the `notes.displayRef` setting.
360+
361A warning will be issued for refs that do not exist, but a glob that
362does not match any refs is silently ignored.
363
Jonathan Niederc5ce1832010-05-08 22:33:28 -0500364'GIT_NOTES_REWRITE_MODE'::
365 When copying notes during a rewrite, what to do if the target
366 commit already has a note.
367 Must be one of `overwrite`, `concatenate`, and `ignore`.
368 This overrides the `core.rewriteMode` setting.
369
370'GIT_NOTES_REWRITE_REF'::
371 When rewriting commits, which notes to copy from the original
372 to the rewritten commit. Must be a colon-delimited list of
373 refs or globs.
374+
375If not set in the environment, the list of notes to copy depends
376on the `notes.rewrite.<command>` and `notes.rewriteRef` settings.
377
Jonathan Nieder00979712010-05-08 22:23:58 -0500378
Johannes Schindelin65d9fb42009-10-09 12:21:58 +0200379Author
380------
Johan Herland7d541172010-02-13 22:28:29 +0100381Written by Johannes Schindelin <johannes.schindelin@gmx.de> and
382Johan Herland <johan@herland.net>
Johannes Schindelin65d9fb42009-10-09 12:21:58 +0200383
384Documentation
385-------------
Johan Herland7d541172010-02-13 22:28:29 +0100386Documentation by Johannes Schindelin and Johan Herland
Johannes Schindelin65d9fb42009-10-09 12:21:58 +0200387
388GIT
389---
390Part of the linkgit:git[7] suite