Synopsis
git notes add [-m <msg>] [<commit>]
git notes show [<commit>]
git notes append [-m <msg>] [<commit>]
git notes remove [<commit>]
Description
The git notes command attaches additional metadata to commits without rewriting them. Notes are stored in their own ref namespace (refs/notes/commits by default) and are displayed alongside commits in git log. Use cases include code review comments, build status, ticket links, or sign-offs added after the fact.
Notes are not pushed by default — you must explicitly git push origin refs/notes/*. Different teams use different namespaces; CI systems often write to refs/notes/ci while reviewers use refs/notes/review.
In day-to-day use, git notes integrates closely with shell aliases, editor plugins, and continuous integration. Power users often add aliases that combine flags they always pass, or wrap the command in scripts that enforce team conventions. Output formatting can be customized via Git config — pretty formats, color schemes, and pager behavior are all tunable. When something goes wrong, the first diagnostic step is usually to re-run the command with GIT_TRACE=1 in the environment, which reveals the underlying plumbing calls. For unusual situations, the --help output (git notes --help) opens the full manual page with details on every option, including those rarely used in casual workflows but essential for debugging or scripting at scale.
Understanding how git notes interacts with the rest of Git's data model — the object database, the index, refs, and the working tree — pays dividends. Each command operates on some subset of these pieces, and knowing which it touches helps predict outcomes and recover from mistakes. Reading the official Git documentation alongside hands-on practice in a throwaway repository is the fastest way to internalize the nuances. Most production issues with Git stem from one of three causes: surprising default behavior, partial network operations, or rewriting history that was already shared. A working mental model of git notes's side effects helps avoid all three.
Common Options
| Subcommand | Description |
|---|---|
add | Attach a new note to a commit. |
append | Add to an existing note. |
edit | Open an editor on the note. |
show | Print the note. |
remove | Delete the note. |
list | List commits that have notes. |
--ref <ref> | Use a different notes namespace. |
Examples
git notes add -m "Reviewed by Alice" abc123
# Attach a review note
git log --show-notes
# Show notes inline with log
git notes --ref=ci add -m "Build #42 passed" HEAD
# Use a custom namespace
git push origin 'refs/notes/*'
# Publish notes to the remote
Common Mistakes
Forgetting to push and fetch the notes ref makes notes invisible to collaborators. Configure notes.displayRef = refs/notes/* so all namespaces show in git log. Notes don't survive history rewrites unless explicitly migrated.
Related Commands
git log, git commit, git push, git fetch