A typical use of git notes is to supplement a commit message without changing the commit itself. Notes can be shown by git log along with the original commit message. To distinguish these notes from the message stored in the commit object, the notes are indented like the message, after an unindented line saying "Notes (
When files are committed into a Git repository, they are addressed by a hash of the contents. The same is true of trees and commits. One of the benefits of this structure is that the objects cannot be modified after they have been committed (since doing so would change that hash).
However, sometimes it is desirable to be able to add metadata to a commit after it has already been committed. There are three ways of doing this:
Amend the commit message to add in the additional metadata, accepting this will change the branch. Create a merge node with a more detailed commit, and push that (so that the previous commit is retained and can be fast forwarded). Add additional metadata in the form of git notes. Of these three options, only the last one will not change the current branch.
Git Notes are, in effect, a separate ‘branch’ of the repository (stored at .git/refs/notes). They don’t show up in the git branch command (that lists .git/refs/heads by default). However, although you could check it out and manually update it, there is a command provided which helps you do that; git notes.
By default, notes are saved to and read from refs/notes/commits, but this default can be overridden. See the OPTIONS, CONFIGURATION, and ENVIRONMENT sections below. If this ref does not exist, it will be quietly created when it is first needed to store a note.
To change which notes are shown by git log, see the "notes.displayRef" configuration in git-log.
You can use notes to add annotations with information that was not available at the time a commit was written. e.g.
$ git notes add -m 'Tested-by: Rachel Gallen<rg@kdbg.net>' 72a144e2
$ git show -s 72a144e
[...]
Signed-off-by: Ruth Escat<gitster@pobox.com>
Notes:
Tested-by: Rachel Gallen <rg@kdbg.net>