git notes
Attach notes to commits without changing them
The 'git notes' command attaches extra text to a commit — a review, a test result, a deployment date — without touching the commit itself, so its hash stays the same. Notes are stored separately (in refs/notes/commits) and git log shows them under the commit message. They are not pushed or fetched by default.
Synopsis
git notes [list [<object>]]
git notes add [-f] [-m <msg>] [<object>]
git notes append [-m <msg>] [<object>]
git notes show [<object>]
git notes remove [<object>...]Options
Choosing the Right Option
Adding information to a commit
Note or amend?
| Command | Hash changes? | Safe after push? |
|---|---|---|
git commit --amend | Yes | No |
git notes add | No | Yes |
Examples
Add a note
git notes add -m "Reviewed by Sam"Attach a note to HEAD.
Note an older commit
git notes add -m "Deployed" a1b2c3dAny commit can get a note.
Share notes
git push origin refs/notes/commitsNotes are only pushed when you ask.
Workflow Examples
git notes add -m "Reviewed by Sam" a1b2c3dAttach the note
git push origin refs/notes/commitsShare it with the team
Troubleshooting
error: Cannot add notes. Found existing notes
Cause: The commit already has a note
Use git notes append, or add -f to replace it
Teammates do not see my notes
Cause: Notes are not pushed by default
git push origin refs/notes/*, and fetch them with git fetch origin refs/notes/*:refs/notes/*
Tips & Pitfalls
Best Practices
- ✓Use notes for information that comes after the commit (reviews, CI results).
Common Mistakes
- ✗Amending a pushed commit just to add information — a note keeps the hash.
- ✗Expecting notes to travel with git push — push refs/notes/* explicitly.
FAQ
No. They are stored beside it; the commit and its hash stay identical.