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