Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/git/blob/master/Documentation/git-notes.adoc # git [Ported from github.com/git/git] Sync with Git 2.56.1 Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `master` Branches Tags History `git / Documentation / git-notes.adoc` 403 lines ยท 14494 bytes Raw Blame History 1 git-notes(1) 2 ============ 3 4 NAME 5 ---- 6 git-notes - Add or inspect object notes 7 8 SYNOPSIS 9 -------- 10 [synopsis] 11 git notes [list []] 12 git notes add [-f] [--allow-empty] [--[no-]separator | --separator=] [--[no-]stripspace] [-F | -m | (-c | -C) ] [-e] [] 13 git notes copy [-f] ( --stdin | [] ) 14 git notes append [--allow-empty] [--[no-]separator | --separator=] [--[no-]stripspace] [-F | -m | (-c | -C) ] [-e] [] 15 git notes edit [--allow-empty] [] [--[no-]stripspace] 16 git notes show [] 17 git notes merge [-v | -q] [-s ] 18 git notes merge --commit [-v | -q] 19 git notes merge --abort [-v | -q] 20 git notes remove [--ignore-missing] [--stdin] [...] 21 git notes prune [-n] [-v] 22 git notes get-ref 23 24 25 DESCRIPTION 26 ----------- 27 Adds, removes, or reads notes attached to objects, without touching 28 the objects themselves. 29 30 By default, notes are saved to and read from `refs/notes/commits`, but 31 this default can be overridden. See the <>, 32 <>, and <> 33 sections below. If this ref does not exist, it will be 34 quietly created when it is first needed to store a note. 35 36 A typical use of notes is to supplement a commit message without 37 changing the commit itself. Notes can be shown by `git log` along with 38 the original commit message. To distinguish these notes from the 39 message stored in the commit object, the notes are indented like the 40 message, after an unindented line saying "Notes (__):" (or 41 "Notes:" for `refs/notes/commits`). 42 43 Notes can also be added to patches prepared with `git format-patch` by 44 using the `--notes` option. Such notes are added as a patch commentary 45 after a three dash separator line. 46 47 To change which notes are shown by `git log`, see the 48 `notes.displayRef` discussion in <>. 49 50 See the `notes.rewrite.` configuration for a way to carry 51 notes across commands that rewrite commits. 52 53 54 SUBCOMMANDS 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 "` `"). 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 ) ` 81 + 82 In `--stdin` mode, take lines in the format 83 + 84 ---------- 85 SP [ SP ] LF 86 ---------- 87 + 88 on standard input, and copy the notes from each __ to its 89 corresponding __. (The optional __ is ignored so that 90 the command can read the input given to the `post-rewrite` hook.) 91 + 92 `--stdin` cannot be combined with object names given on the command 93 line. 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 + 117 If conflicts arise and a strategy for automatically resolving 118 conflicting notes (see the 119 <> section) is not given, 120 the `manual` resolver is used. This resolver checks out the 121 conflicting notes in a special worktree (`.git/NOTES_MERGE_WORKTREE`), 122 and instructs the user to manually resolve the conflicts there. 123 When 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 + 133 In `--stdin` mode, also remove the object names given on standard 134 input. In other words, `--stdin` can be combined with object names from 135 the 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]] 145 OPTIONS 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 `:: 153 `--message=`:: 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 `:: 159 `--file=`:: 160 Take the note message from the given file. Use `-` to 161 read the note message from the standard input. 162 163 `-C `:: 164 `--reuse-message=`:: 165 Take the given blob object (for example, another note) as the 166 note message. (Use `git notes copy ` instead to 167 copy notes between objects.) Implies `--no-stripspace` since 168 the default behavior is to copy the message verbatim. 169 170 `-c `:: 171 `--reedit-message=`:: 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=`:: 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 201 order of similar options. For example, for `-C -m`, 202 `--stripspace` will be used because the default for `-m` overrides the 203 previous `-C`. This is a known limitation that may be fixed in the 204 future. 205 206 `--ref=`:: 207 Manipulate the notes tree in __. 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 `:: 226 `--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 <> 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 260 DISCUSSION 261 ---------- 262 263 Commit notes are blobs containing extra information about an object 264 (usually information to supplement a commit's message). These blobs 265 are taken from notes refs. A notes ref is usually a branch which 266 contains "files" whose paths are the object names for the objects 267 they describe, with some directory separators included for performance 268 reasons footnote:[Permitted pathnames have the form 269 'bf'`/`'fe'`/`'30'`/`'...'`/`'680d5a...': a sequence of directory 270 names of two hexadecimal digits each followed by a filename with the 271 rest of the object ID.]. 272 273 Every notes change creates a new commit at the specified notes ref. 274 You can therefore inspect the history of the notes by invoking, e.g., 275 `git log -p notes/commits`. Currently the commit message only records 276 which operation triggered the update, and the commit authorship is 277 determined according to the usual rules (see linkgit:git-commit[1]). 278 These details may change in the future. 279 280 It is also permitted for a notes ref to point directly to a tree 281 object, in which case the history of the notes can be read with 282 `git log -p -g `. 283 284 285 [[NOTES_MERGE_STRATEGIES]] 286 NOTES MERGE STRATEGIES 287 ---------------------- 288 289 The default notes merge strategy is `manual`, which checks out 290 conflicting notes in a special work tree for resolving notes conflicts 291 (`.git/NOTES_MERGE_WORKTREE`), and instructs the user to resolve the 292 conflicts in that work tree. 293 When 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 297 Users may select an automated merge strategy from among the following using 298 either `-s`/`--strategy` option or configuring `notes.mergeStrategy` accordingly: 299 300 `ours` automatically resolves conflicting notes in favor of the local 301 version (i.e. the current notes ref). 302 303 `theirs` automatically resolves notes conflicts in favor of the remote 304 version (i.e. the given notes ref being merged into the current notes 305 ref). 306 307 `union` automatically resolves notes conflicts by concatenating the 308 local and remote versions. 309 310 `cat_sort_uniq` is similar to `union`, but in addition to concatenating 311 the local and remote versions, this strategy also sorts the resulting 312 lines, and removes duplicate lines from the result. This is equivalent 313 to applying the "cat | sort | uniq" shell pipeline to the local and 314 remote versions. This strategy is useful if the notes follow a line-based 315 format where one wants to avoid duplicated lines in the merge result. 316 Note that if either the local or remote version contain duplicate lines 317 prior to the merge, these will also be removed by this notes merge 318 strategy. 319 320 321 EXAMPLES 322 -------- 323 324 You can use notes to add annotations with information that was not 325 available at the time a commit was written. 326 327 ------------ 328 $ git notes add -m 'Tested-by: Johannes Sixt ' `72a144e2` 329 $ git show -s `72a144e` 330 [...] 331 Signed-off-by: Junio C Hamano 332 333 Notes: 334 Tested-by: Johannes Sixt 335 ------------ 336 337 In principle, a note is a regular Git blob, and any kind of 338 (non-)format is accepted. You can binary-safely create notes from 339 arbitrary 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` 348 because that is not binary-safe.) 349 Of course, it doesn't make much sense to display non-text-format notes 350 with `git log`, so if you use such notes, you'll probably need to write 351 some special-purpose tools to do something useful with them. 352 353 354 [[CONFIGURATION]] 355 CONFIGURATION 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 364 include::includes/cmd-config-section-rest.adoc[] 365 366 include::config/notes.adoc[] 367 368 369 [[ENVIRONMENT]] 370 ENVIRONMENT 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 + 384 A warning will be issued for refs that do not exist, but a glob that 385 does 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 + 398 If not set in the environment, the list of notes to copy depends 399 on the `notes.rewrite.` and `notes.rewriteRef` settings. 400 401 GIT 402 --- 403 Part of the linkgit:git[1] suite