GIT-NOTES(1)
π GIT-NOTES(1) π
okay bestie, welcome to the git-notes glow-up β¨ (that's from the Git Manual, mwah π ). This is the page about adding or inspecting object notes, and yes we're gonna get through all of it together, no cap π«Ά
πΈ NAME πΈ
git-notes β add or inspect object notes π
β¨ SYNOPSIS β¨
git notes [list [<object>]]
git notes add [-f] [--allow-empty] [--[no-]separator | --separator=<paragraph-break>] [--[no-]stripspace] [-F <file> | -m <msg> | (-c | -C) <object>] [-e] [<object>]
git notes copy [-f] ( --stdin | <from-object> [<to-object>] )
git notes append [--allow-empty] [--[no-]separator | --separator=<paragraph-break>] [--[no-]stripspace] [-F <file> | -m <msg> | (-c | -C) <object>] [-e] [<object>]
git notes edit [--allow-empty] [<object>] [--[no-]stripspace]
git notes show [<object>]
git notes merge [-v | -q] [-s <strategy> ] <notes-ref>
git notes merge --commit [-v | -q]
git notes merge --abort [-v | -q]
git notes remove [--ignore-missing] [--stdin] [<object>...]
git notes prune [-n] [-v]
git notes get-ref
π¦ DESCRIPTION π¦
So basically: this command adds, removes, or reads notes that are attached to objects β and the whole point is it does that without touching the objects themselves. Like, the object stays iconic, the note is just the little sticky note on top π
By default, notes get saved to and read from refs/notes/commits, but that default can absolutely be overridden. Peep the OPTIONS, CONFIGURATION, and ENVIRONMENT sections below for that π. And if this ref doesn't exist yet? It'll be quietly created the first time it's actually needed to store a note. No drama, it just happens.
A classic use of notes is to supplement a commit message without changing the commit itself. Notes can be shown by git log right alongside the original commit message π. And to tell these notes apart from the message stored in the commit object, the notes get indented like the message, after an unindented line saying "Notes (<refname>):" β or just "Notes:" for refs/notes/commits.
Notes can also be added to patches prepared with git format-patch by using the --notes option β those notes get added as patch commentary after a three dash separator line. slay β¨
Wanna change which notes get shown by git log? Go read the notes.displayRef discussion in CONFIGURATION.
And see the notes.rewrite.<command> configuration for a way to carry notes across commands that rewrite commits. very handy, iykyk π§
π SUBCOMMANDS π
listβ List the notes object for a given object. If you don't give it an object, it shows a list of all note objects and the objects they annotate, in the format"<note-object> <annotated-object>". This is the default subcommand if you don't give any subcommand at all β main character energy, it just steps up πaddβ Add notes for a given object (defaults toHEAD). It aborts if the object already has notes (use-fto overwrite the existing ones). But β if you're usingaddinteractively (like, using an editor to supply the notes contents), then instead of aborting, the existing notes get opened in the editor, just like theeditsubcommand. Cute, right? If you specify multiple-mand-F, a blank line gets inserted between the messages. Use the--separatoroption to insert other delimiters. And you can use-eto edit and fine-tune the message(s) supplied from-mand-Foptions interactively (using an editor) before adding the note πcopyβ Copy the notes for the first object onto the second object (defaults toHEAD). It aborts if the second object already has notes, or if the first object has none (use-fto overwrite existing notes on the second object). This subcommand is equivalent to:
git notes add [-f] -C $(git notes list <from-object>) <to-object>
In --stdin mode, take lines in the format
<from-object> SP <to-object> [ SP <rest> ] LF
on standard input, and copy the notes from each <from-object> to its corresponding <to-object>. (The optional <rest> is ignored so that the command can read the input given to the post-rewrite hook.)
--stdin cannot be combined with object names given on the command line. periodt π«
appendβ Append new message(s) given by-mor-Foptions to an existing note, or add them as a new note if one doesn't exist, for the object (defaults toHEAD). When appending to an existing note, a blank line gets added before each new message as an inter-paragraph separator β and you can customize that separator with the--separatoroption β¨. Edit the notes to be appended given by-mand-Foptions with-einteractively (using an editor) before appending the note.editβ Edit the notes for a given object (defaults toHEAD). go off βοΈshowβ Show the notes for a given object (defaults toHEAD). peekaboo πmergeβ Merge the given notes ref into the current notes ref. This tries to merge the changes made by the given notes ref (called "remote") since the merge-base (if any) into the current notes ref (called "local").
If conflicts arise and a strategy for automatically resolving conflicting notes (see the "NOTES MERGE STRATEGIES" section) is not given, the manual resolver gets used. That resolver checks out the conflicting notes in a special worktree (.git/NOTES_MERGE_WORKTREE) and instructs the user to manually resolve the conflicts there π. When you're done, you can either finalize the merge with git notes merge --commit, or abort the merge with git notes merge --abort.
removeβ Remove the notes for given objects (defaults toHEAD). When giving zero or one object from the command line, this is equivalent to specifying an empty note message to theeditsubcommand.
In --stdin mode, it also removes the object names given on standard input. In other words, --stdin can be combined with object names from the command line π
pruneβ Remove all notes for non-existing/unreachable objects. bye bye π§Ήget-refβ Print the current notes ref. This is the easy way to retrieve the current notes ref (like, from scripts). π―
π OPTIONS π
-f,--forceβ When adding notes to an object that already has notes, overwrite the existing notes (instead of aborting). no thoughts, just force π₯-m <msg>,--message=<msg>β Use the given note message (instead of prompting). If multiple-moptions are given, their values get concatenated as separate paragraphs.-F <file>,--file=<file>β Take the note message from the given file. Use-to read the note message from the standard input.-C <object>,--reuse-message=<object>β Take the given blob object (for example, another note) as the note message. (Usegit notes copy <object>instead to copy notes between objects.) This implies--no-stripspace, since the default behavior is to copy the message verbatim π«Ά-c <object>,--reedit-message=<object>β Like-C, but with-cthe editor gets invoked, so you can further edit the note message. βοΈ--allow-emptyβ Allow an empty note object to be stored. The default behavior is to automatically remove empty notes. (yes it's giving "why would you" but the option is right there π)--separator=<paragraph-break>,--separator,--no-separatorβ Specify a string used as a custom inter-paragraph separator (a newline gets added at the end as needed). If--no-separator, no separators will be added between paragraphs at all. Defaults to a blank line.--stripspace,--no-stripspaceβ Clean up whitespace. Specifically (seegit-stripspace(1)):- remove trailing whitespace from all lines
- collapse multiple consecutive empty lines into one empty line
- remove empty lines from the beginning and end of the input
- add a missing
\nto the last line if necessary.
--stripspace is the default except for -C/--reuse-message. BUT keep in mind that this depends on the order of similar options π. For example, for -C <object> -m<message>, --stripspace will be used because the default for -m overrides the previous -C. This is a known limitation that may be fixed in the future. (we're aware, we're aware π)
--ref=<ref>β Manipulate the notes tree in<ref>. This overridesGIT_NOTES_REFand thecore.notesRefconfiguration. The ref specifies the full refname when it begins withrefs/notes/; when it begins withnotes/,refs/gets prefixed, and otherwiserefs/notes/gets prefixed, to form a full name of the ref β¨--ignore-missingβ Do not consider it an error to request removing notes from an object that doesn't have notes attached to it. be nice π--stdinβ Only valid forremoveandcopy. See the respective subcommands.-n,--dry-runβ Do not remove anything; just report the object names whose notes would be removed. window shopping ποΈ-s <strategy>,--strategy=<strategy>β When merging notes, resolve notes conflicts using the given strategy. The following strategies are recognized:manual(default),ours,theirs,unionandcat_sort_uniq. This option overrides thenotes.mergeStrategyconfiguration setting. See the "NOTES MERGE STRATEGIES" section below for more info on each notes merge strategy π--commitβ Finalize an in-progressgit notes merge. Use this option when you've resolved the conflicts thatgit notes mergestored in.git/NOTES_MERGE_WORKTREE. This amends the partial merge commit created bygit notes merge(stored in.git/NOTES_MERGE_PARTIAL) by adding the notes in.git/NOTES_MERGE_WORKTREE. The notes ref stored in the.git/NOTES_MERGE_REFsymref gets updated to the resulting commit. wrap it up bestie π--abortβ Abort/reset an in-progressgit notes merge, i.e. a notes merge with conflicts. This simply removes all files related to the notes merge. nvm, forget it π-q,--quietβ When merging notes, operate quietly. shhh π€«-v,--verboseβ When merging notes, be more verbose. When pruning notes, report all object names whose notes are removed. tell me everything π£οΈ
π DISCUSSION π
Commit notes are blobs containing extra information about an object (usually information to supplement a commit's message). These blobs get taken from notes refs. A notes ref is usually a branch which contains "files" whose paths are the object names for the objects they describe, with some directory separators included for performance reasons [1]. iykyk π§
Every notes change creates a new commit at the specified notes ref. So you can totally inspect the history of the notes by invoking, e.g., git log -p notes/commits. Currently the commit message only records which operation triggered the update, and the commit authorship is determined according to the usual rules (see git-commit(1)). These details may change in the future β so don't get too attached π
It's also permitted for a notes ref to point directly to a tree object, in which case the history of the notes can be read with git log -p -g <refname>. iconic β
π«Ά NOTES MERGE STRATEGIES π«Ά
okay so the default notes merge strategy is manual, and bestie it literally checks out conflicting notes in a special work tree for resolving notes conflicts at .git/NOTES_MERGE_WORKTREE, then tells you to go resolve the conflicts in that work tree. when youβre done, you can either finalize the merge with git notes merge --commit, or abort the merge with git notes merge --abort. iconic.
you can pick an automated merge strategy from the list below using either the -s/--strategy option or by configuring notes.mergeStrategy accordingly:
oursβ automatically resolves conflicting notes in favor of the local version (i.e. the current notes ref).theirsβ automatically resolves notes conflicts in favor of the remote version (i.e. the given notes ref being merged into the current notes ref).unionβ automatically resolves notes conflicts by concatenating the local and remote versions.cat_sort_uniqβ similar tounion, but in addition to concatenating the local and remote versions, this strategy also sorts the resulting lines, and removes duplicate lines from the result. this is equivalent to applying the"cat | sort | uniq"shell pipeline to the local and remote versions. this strategy is useful if the notes follow a line-based format where one wants to avoid duplicated lines in the merge result. note that if either the local or remote version contain duplicate lines prior to the merge, these will also be removed by this notes merge strategy.
β¨ EXAMPLES β¨
you can use notes to add annotations with information that was not available at the time a commit was written. obsessed with the historical receipts π
$ git notes add -m 'Tested-by: Johannes Sixt <j6t@kdbg.org>' 72a144e2
$ git show -s 72a144e
[...]
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Notes:
Tested-by: Johannes Sixt <j6t@kdbg.org>
in principle, a note is a regular Git blob, and any kind of (non-)format is accepted. you can binary-safely create notes from arbitrary files using git hash-object:
$ cc *.c
$ blob=$(git hash-object -w a.out)
$ git notes --ref=built add --allow-empty -C "$blob" HEAD
(you cannot simply use git notes --ref=built add -F a.out HEAD because that is not binary-safe.) π«Ά
of course, it doesnβt make much sense to display non-text-format notes with git log, so if you use such notes, youβll probably need to write some special-purpose tools to do something useful with them.
π CONFIGURATION π
core.notesRefβ Notes ref to read and manipulate instead ofrefs/notes/commits. Must be an unabbreviated ref name. This setting can be overridden through the environment and command line.
quick meta note: everything above this line in this section isnβt included from the git-config(1) documentation. the content that follows is the same as whatβs found there:
notes.mergeStrategyβ Which merge strategy to choose by default when resolving notes conflicts. Must be one ofmanual,ours,theirs,union, orcat_sort_uniq. Defaults tomanual. See the "NOTES MERGE STRATEGIES" section ofgit-notes(1)for more information on each strategy. This setting can be overridden by passing the--strategyoption togit-notes(1).notes.<name>.mergeStrategyβ Which merge strategy to choose when doing a notes merge intorefs/notes/<name>. This overrides the more generalnotes.mergeStrategy. See the "NOTES MERGE STRATEGIES" section ingit-notes(1)for more information on the available strategies.notes.displayRefβ Which ref (or refs, if a glob or specified more than once), in addition to the default set bycore.notesReforGIT_NOTES_REF, to read notes from when showing commit messages with thegit logfamily of commands. This setting can be overridden with theGIT_NOTES_DISPLAY_REFenvironment variable, which must be a colon separated list of refs or globs. A warning will be issued for refs that do not exist, but a glob that does not match any refs is silently ignored. This setting can be disabled by the--no-notesoption to thegit-log(1)family of commands, or by the--notes=<ref>option accepted by those commands. The effective value ofcore.notesRef(possibly overridden byGIT_NOTES_REF) is also implicitly added to the list of refs to be displayed.notes.rewrite.<command>β When rewriting commits with<command>(currentlyamendorrebase), if this variable is false, git will not copy notes from the original to the rewritten commit. Defaults totrue. See alsonotes.rewriteRefbelow. This setting can be overridden with theGIT_NOTES_REWRITE_REFenvironment variable, which must be a colon separated list of refs or globs.notes.rewriteModeβ When copying notes during a rewrite (see thenotes.rewrite.<command>option), determines what to do if the target commit already has a note. Must be one ofoverwrite,concatenate,cat_sort_uniq, orignore. Defaults toconcatenate. This setting can be overridden with theGIT_NOTES_REWRITE_MODEenvironment variable.notes.rewriteRefβ When copying notes during a rewrite, specifies the (fully qualified) ref whose notes should be copied. May be a glob, in which case notes in all matching refs will be copied. You may also specify this configuration several times. Does not have a default value; you must configure this variable to enable note rewriting. Set it torefs/notes/commitsto enable rewriting for the default commit notes. Can be overridden with theGIT_NOTES_REWRITE_REFenvironment variable. Seenotes.rewrite.<command>above for a further description of its format.
π ENVIRONMENT π
GIT_NOTES_REFβ Which ref to manipulate notes from, instead ofrefs/notes/commits. This overrides thecore.notesRefsetting.GIT_NOTES_DISPLAY_REFβ Colon-delimited list of refs or globs indicating which refs, in addition to the default fromcore.notesReforGIT_NOTES_REF, to read notes from when showing commit messages. This overrides thenotes.displayRefsetting. A warning will be issued for refs that do not exist, but a glob that does not match any refs is silently ignored.GIT_NOTES_REWRITE_MODEβ When copying notes during a rewrite, what to do if the target commit already has a note. Must be one ofoverwrite,concatenate,cat_sort_uniq, orignore. This overrides thecore.rewriteModesetting.GIT_NOTES_REWRITE_REFβ When rewriting commits, which notes to copy from the original to the rewritten commit. Must be a colon-delimited list of refs or globs. If not set in the environment, the list of notes to copy depends on thenotes.rewrite.<command>andnotes.rewriteRefsettings.
π GIT π
part of the git(1) suite. the family tree stays iconic β¨
π NOTES π
- Permitted pathnames have the form
bf/fe/30/.../680d5a...: a sequence of directory names of two hexadecimal digits each followed by a filename with the rest of the object ID.
okay bestie, thatβs the whole GIT-NOTES(1) page π source/version: Git 2.56.0; date: 2026-09-27 β you ate, periodt π«Άβ¨
π¦ where this page comes from
- arch rolling: git 2.56.0-1 Β· GPL-2.0-only
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms