Skip to main content

How to Add Extra Information to Commits with Git Notes

Short answer

git notes lets you attach arbitrary text annotations to any existing commit without modifying the commit itself or changing its hash, keeping the annotation separate from the permanent commit record. Add a note to the current commit with git notes add -m "Your annotation", or to a specific commit with git notes add -m "Note" <commit-hash>; edit an existing note with git notes edit <commit-hash>. Notes are stored in a separate ref namespace (refs/notes/commits) and do not appear by default in git log — use git log --show-notes or git notes show <hash> to display them. To share notes with collaborators you must explicitly push them: git push origin refs/notes/commits, and others must explicitly fetch: git fetch origin refs/notes/commits. Practical use cases include attaching CI build results, deployment records, or post-review annotations to commits after the fact without rewriting history.

In a hurry? Watch our brief 1-minute vertical video that summarizes the info below.

Have you ever wanted to add some information to a commit after it has been created? Since commits in Git are immutable, you can't change them.

However, Git provides a clever solution for this: git notes!

Git Notes allows you to attach extra information, or "notes", to any commit without changing the commit's hash. This is perfect for adding context like bug tracker IDs, QA notes, or any other metadata.

Adding and Viewing Notes

To add a note to the most recent commit, you can use the git notes add command with the -m flag:

git notes add -m "Fixes bug #123" HEAD

If you want to add a more detailed note, you can omit the -m flag, and Git will open your default text editor.

You can also specify a particular commit hash:

git notes add <commit-hash>

To see the note for a specific commit, use git notes show:

git notes show <commit-hash>

Managing Your Notes

To see a list of all your notes, you can use the git notes list command. This will show you the hash of the note object and the hash of the commit it's attached to.

git notes list

If you want to remove a note from a commit, simply use git notes remove:

git notes remove <commit-hash>

The Git Cheat Sheet

No need to remember all those commands and parameters: get our popular "Git Cheat Sheet" - for free!

Free. We email you a ZIP with our cheat sheets.

Sharing Notes with Your Team

It's very important to understand that notes are not shared with your team by default. A git push or git pull will not include notes.

To share your notes, you must explicitly push the notes reference:

git push origin refs/notes/commits

Similarly, to get notes from a remote repository, your collaborators must fetch them explicitly:

git fetch origin refs/notes/commits:refs/notes/commits

After you've done this once, Git will remember to keep the notes in sync on subsequent push and fetch operations for that repository.

Free download

Download the Cheat Sheet

Get 18 of our most popular Cheat Sheets in one handy ZIP!