interplane.Get Omega
Read in your language

git

[Ported from github.com/git/git] Sync with Git 2.56.1

Brought by drakestapleton

branch master Branches Tags History

git / Documentation / git-notes.adoc

403 lines · 14494 bytes Raw Blame History
1git-notes(1)
2============
3
4NAME
5----
6git-notes - Add or inspect object notes
7
8SYNOPSIS
9--------
10[synopsis]
11git notes [list [<object>]]
12git notes add [-f] [--allow-empty] [--[no-]separator | --separator=<paragraph-break>] [--[no-]stripspace] [-F <file> | -m <msg> | (-c | -C) <object>] [-e] [<object>]
13git notes copy [-f] ( --stdin | <from-object> [<to-object>] )
14git notes append [--allow-empty] [--[no-]separator | --separator=<paragraph-break>] [--[no-]stripspace] [-F <file> | -m <msg> | (-c | -C) <object>] [-e] [<object>]
15git notes edit [--allow-empty] [<object>] [--[no-]stripspace]
16git notes show [<object>]
17git notes merge [-v | -q] [-s <strategy> ] <notes-ref>
18git notes merge --commit [-v | -q]
19git notes merge --abort [-v | -q]
20git notes remove [--ignore-missing] [--stdin] [<object>...]
21git notes prune [-n] [-v]
22git notes get-ref
23
24
25DESCRIPTION
26-----------
27Adds, removes, or reads notes attached to objects, without touching
28the objects themselves.
29
30By default, notes are saved to and read from `refs/notes/commits`, but
31this default can be overridden. See the <<OPTIONS,OPTIONS>>,
32<<CONFIGURATION,CONFIGURATION>>, and <<ENVIRONMENT,ENVIRONMENT>>
33sections below. If this ref does not exist, it will be
34quietly created when it is first needed to store a note.
35
36A typical use of notes is to supplement a commit message without
37changing the commit itself. Notes can be shown by `git log` along with
38the original commit message. To distinguish these notes from the
39message stored in the commit object, the notes are indented like the
40message, after an unindented line saying "Notes (_<refname>_):" (or
41"Notes:" for `refs/notes/commits`).
42
43Notes can also be added to patches prepared with `git format-patch` by
44using the `--notes` option. Such notes are added as a patch commentary
45after a three dash separator line.
46
47To change which notes are shown by `git log`, see the
48`notes.displayRef` discussion in <<CONFIGURATION,CONFIGURATION>>.
49
50See the `notes.rewrite.<command>` configuration for a way to carry
51notes across commands that rewrite commits.
52
53
54SUBCOMMANDS
55-----------
56
57`list`::
58 List the notes object for a given object. If no object is
59 given, show a list of all note objects and the objects they
60 annotate (in the format "`<note-object> <annotated-object>`").
61 This is the default subcommand if no subcommand is given.
62
63`add`::
64 Add notes for a given object (defaults to `HEAD`). Abort if the
65 object already has notes (use `-f` to overwrite existing notes).
66 However, if you're using `add` interactively (using an editor
67 to supply the notes contents), then - instead of aborting -
68 the existing notes will be opened in the editor (like the `edit`
69 subcommand). If you specify multiple `-m` and `-F`, a blank
70 line will be inserted between the messages. Use the `--separator`
71 option to insert other delimiters. You can use `-e` to edit and
72 fine-tune the message(s) supplied from `-m` and `-F` options
73 interactively (using an editor) before adding the note.
74
75`copy`::
76 Copy the notes for the first object onto the second object (defaults to
77 `HEAD`). Abort if the second object already has notes, or if the first
78 object has none (use `-f` to overwrite existing notes to the
79 second object). This subcommand is equivalent to:
80 `git notes add [-f] -C $(git notes list <from-object>) <to-object>`
81+
82In `--stdin` mode, take lines in the format
83+
84----------
85<from-object> SP <to-object> [ SP <rest> ] LF
86----------
87+
88on standard input, and copy the notes from each _<from-object>_ to its
89corresponding _<to-object>_. (The optional _<rest>_ is ignored so that
90the command can read the input given to the `post-rewrite` hook.)
91+
92`--stdin` cannot be combined with object names given on the command
93line.
94
95`append`::
96 Append new message(s) given by `-m` or `-F` options to an
97 existing note, or add them as a new note if one does not
98 exist, for the object (defaults to `HEAD`). When appending to
99 an existing note, a blank line is added before each new
100 message as an inter-paragraph separator. The separator can
101 be customized with the `--separator` option.
102 Edit the notes to be appended given by `-m` and `-F` options with
103 `-e` interactively (using an editor) before appending the note.
104
105`edit`::
106 Edit the notes for a given object (defaults to `HEAD`).
107
108`show`::
109 Show the notes for a given object (defaults to `HEAD`).
110
111`merge`::
112 Merge the given notes ref into the current notes ref.
113 This will try to merge the changes made by the given
114 notes ref (called "remote") since the merge-base (if
115 any) into the current notes ref (called "local").
116+
117If conflicts arise and a strategy for automatically resolving
118conflicting notes (see the
119<<NOTES_MERGE_STRATEGIES,"NOTES MERGE STRATEGIES">> section) is not given,
120the `manual` resolver is used. This resolver checks out the
121conflicting notes in a special worktree (`.git/NOTES_MERGE_WORKTREE`),
122and instructs the user to manually resolve the conflicts there.
123When done, the user can either finalize the merge with
124`git notes merge --commit`, or abort the merge with
125`git notes merge --abort`.
126
127`remove`::
128 Remove the notes for given objects (defaults to `HEAD`). When
129 giving zero or one object from the command line, this is
130 equivalent to specifying an empty note message to
131 the `edit` subcommand.
132+
133In `--stdin` mode, also remove the object names given on standard
134input. In other words, `--stdin` can be combined with object names from
135the command line.
136
137`prune`::
138 Remove all notes for non-existing/unreachable objects.
139
140`get-ref`::
141 Print the current notes ref. This provides an easy way to
142 retrieve the current notes ref (e.g. from scripts).
143
144[[OPTIONS]]
145OPTIONS
146-------
147`-f`::
148`--force`::
149 When adding notes to an object that already has notes,
150 overwrite the existing notes (instead of aborting).
151
152`-m <msg>`::
153`--message=<msg>`::
154 Use the given note message (instead of prompting).
155 If multiple `-m` options are given, their values
156 are concatenated as separate paragraphs.
157
158`-F <file>`::
159`--file=<file>`::
160 Take the note message from the given file. Use `-` to
161 read the note message from the standard input.
162
163`-C <object>`::
164`--reuse-message=<object>`::
165 Take the given blob object (for example, another note) as the
166 note message. (Use `git notes copy <object>` instead to
167 copy notes between objects.) Implies `--no-stripspace` since
168 the default behavior is to copy the message verbatim.
169
170`-c <object>`::
171`--reedit-message=<object>`::
172 Like `-C`, but with `-c` the editor is invoked, so that
173 the user can further edit the note message.
174
175`--allow-empty`::
176 Allow an empty note object to be stored. The default behavior is
177 to automatically remove empty notes.
178
179`--separator=<paragraph-break>`::
180`--separator`::
181`--no-separator`::
182 Specify a string used as a custom inter-paragraph separator
183 (a newline is added at the end as needed). If `--no-separator`, no
184 separators will be added between paragraphs. Defaults to a blank
185 line.
186
187`--stripspace`::
188`--no-stripspace`::
189 Clean up whitespace. Specifically (see
190 linkgit:git-stripspace[1]):
191+
192--
193- remove trailing whitespace from all lines
194- collapse multiple consecutive empty lines into one empty line
195- remove empty lines from the beginning and end of the input
196- add a missing `\n` to the last line if necessary.
197--
198+
199`--stripspace` is the default except for
200`-C`/`--reuse-message`. However, keep in mind that this depends on the
201order of similar options. For example, for `-C <object> -m<message>`,
202`--stripspace` will be used because the default for `-m` overrides the
203previous `-C`. This is a known limitation that may be fixed in the
204future.
205
206`--ref=<ref>`::
207 Manipulate the notes tree in _<ref>_. This overrides
208 `GIT_NOTES_REF` and the `core.notesRef` configuration. The ref
209 specifies the full refname when it begins with `refs/notes/`; when it
210 begins with `notes/`, `refs/` and otherwise `refs/notes/` is prefixed
211 to form a full name of the ref.
212
213`--ignore-missing`::
214 Do not consider it an error to request removing notes from an
215 object that does not have notes attached to it.
216
217`--stdin`::
218 Only valid for `remove` and `copy`. See the respective subcommands.
219
220`-n`::
221`--dry-run`::
222 Do not remove anything; just report the object names whose notes
223 would be removed.
224
225`-s <strategy>`::
226`--strategy=<strategy>`::
227 When merging notes, resolve notes conflicts using the given
228 strategy. The following strategies are recognized: `manual`
229 (default), `ours`, `theirs`, `union` and `cat_sort_uniq`.
230 This option overrides the `notes.mergeStrategy` configuration setting.
231 See the <<NOTES_MERGE_STRATEGIES,"NOTES MERGE STRATEGIES">>
232 section below for more
233 information on each notes merge strategy.
234
235`--commit`::
236 Finalize an in-progress `git notes merge`. Use this option
237 when you have resolved the conflicts that `git notes merge`
238 stored in `.git/NOTES_MERGE_WORKTREE`. This amends the partial
239 merge commit created by `git notes merge` (stored in
240 `.git/NOTES_MERGE_PARTIAL`) by adding the notes in
241 `.git/NOTES_MERGE_WORKTREE`. The notes ref stored in the
242 `.git/NOTES_MERGE_REF` symref is updated to the resulting commit.
243
244`--abort`::
245 Abort/reset an in-progress `git notes merge`, i.e. a notes merge
246 with conflicts. This simply removes all files related to the
247 notes merge.
248
249`-q`::
250`--quiet`::
251 When merging notes, operate quietly.
252
253`-v`::
254`--verbose`::
255 When merging notes, be more verbose.
256 When pruning notes, report all object names whose notes are
257 removed.
258
259
260DISCUSSION
261----------
262
263Commit notes are blobs containing extra information about an object
264(usually information to supplement a commit's message). These blobs
265are taken from notes refs. A notes ref is usually a branch which
266contains "files" whose paths are the object names for the objects
267they describe, with some directory separators included for performance
268reasons footnote:[Permitted pathnames have the form
269'bf'`/`'fe'`/`'30'`/`'...'`/`'680d5a...': a sequence of directory
270names of two hexadecimal digits each followed by a filename with the
271rest of the object ID.].
272
273Every notes change creates a new commit at the specified notes ref.
274You can therefore inspect the history of the notes by invoking, e.g.,
275`git log -p notes/commits`. Currently the commit message only records
276which operation triggered the update, and the commit authorship is
277determined according to the usual rules (see linkgit:git-commit[1]).
278These details may change in the future.
279
280It is also permitted for a notes ref to point directly to a tree
281object, in which case the history of the notes can be read with
282`git log -p -g <refname>`.
283
284
285[[NOTES_MERGE_STRATEGIES]]
286NOTES MERGE STRATEGIES
287----------------------
288
289The default notes merge strategy is `manual`, which checks out
290conflicting notes in a special work tree for resolving notes conflicts
291(`.git/NOTES_MERGE_WORKTREE`), and instructs the user to resolve the
292conflicts in that work tree.
293When done, the user can either finalize the merge with
294`git notes merge --commit`, or abort the merge with
295`git notes merge --abort`.
296
297Users may select an automated merge strategy from among the following using
298either `-s`/`--strategy` option or configuring `notes.mergeStrategy` accordingly:
299
300`ours` automatically resolves conflicting notes in favor of the local
301version (i.e. the current notes ref).
302
303`theirs` automatically resolves notes conflicts in favor of the remote
304version (i.e. the given notes ref being merged into the current notes
305ref).
306
307`union` automatically resolves notes conflicts by concatenating the
308local and remote versions.
309
310`cat_sort_uniq` is similar to `union`, but in addition to concatenating
311the local and remote versions, this strategy also sorts the resulting
312lines, and removes duplicate lines from the result. This is equivalent
313to applying the "cat | sort | uniq" shell pipeline to the local and
314remote versions. This strategy is useful if the notes follow a line-based
315format where one wants to avoid duplicated lines in the merge result.
316Note that if either the local or remote version contain duplicate lines
317prior to the merge, these will also be removed by this notes merge
318strategy.
319
320
321EXAMPLES
322--------
323
324You can use notes to add annotations with information that was not
325available at the time a commit was written.
326
327------------
328$ git notes add -m 'Tested-by: Johannes Sixt <j6t@kdbg.org>' 72a144e2
329$ git show -s 72a144e
330[...]
331 Signed-off-by: Junio C Hamano <gitster@pobox.com>
332
333Notes:
334 Tested-by: Johannes Sixt <j6t@kdbg.org>
335------------
336
337In principle, a note is a regular Git blob, and any kind of
338(non-)format is accepted. You can binary-safely create notes from
339arbitrary files using `git hash-object`:
340
341------------
342$ cc *.c
343$ blob=$(git hash-object -w a.out)
344$ git notes --ref=built add --allow-empty -C "$blob" HEAD
345------------
346
347(You cannot simply use `git notes --ref=built add -F a.out HEAD`
348because that is not binary-safe.)
349Of course, it doesn't make much sense to display non-text-format notes
350with `git log`, so if you use such notes, you'll probably need to write
351some special-purpose tools to do something useful with them.
352
353
354[[CONFIGURATION]]
355CONFIGURATION
356-------------
357
358`core.notesRef`::
359 Notes ref to read and manipulate instead of
360 `refs/notes/commits`. Must be an unabbreviated ref name.
361 This setting can be overridden through the environment and
362 command line.
363
364include::includes/cmd-config-section-rest.adoc[]
365
366include::config/notes.adoc[]
367
368
369[[ENVIRONMENT]]
370ENVIRONMENT
371-----------
372
373`GIT_NOTES_REF`::
374 Which ref to manipulate notes from, instead of `refs/notes/commits`.
375 This overrides the `core.notesRef` setting.
376
377`GIT_NOTES_DISPLAY_REF`::
378 Colon-delimited list of refs or globs indicating which refs,
379 in addition to the default from `core.notesRef` or
380 `GIT_NOTES_REF`, to read notes from when showing commit
381 messages.
382 This overrides the `notes.displayRef` setting.
383+
384A warning will be issued for refs that do not exist, but a glob that
385does not match any refs is silently ignored.
386
387`GIT_NOTES_REWRITE_MODE`::
388 When copying notes during a rewrite, what to do if the target
389 commit already has a note.
390 Must be one of `overwrite`, `concatenate`, `cat_sort_uniq`, or `ignore`.
391 This overrides the `core.rewriteMode` setting.
392
393`GIT_NOTES_REWRITE_REF`::
394 When rewriting commits, which notes to copy from the original
395 to the rewritten commit. Must be a colon-delimited list of
396 refs or globs.
397+
398If not set in the environment, the list of notes to copy depends
399on the `notes.rewrite.<command>` and `notes.rewriteRef` settings.
400
401GIT
402---
403Part of the linkgit:git[1] suite