How to Add Extra Information to Commits with Git Notes
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!
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.
Download the Cheat SheetFree
Get 18 of our most popular Cheat Sheets in one handy ZIP!

Thanks! Please Check Your Inbox!
Want to win one of our awesome Tower shirts?
Tell your friends about the package!
