Why You Should Use Git Notes Instead of Amend?
You just pushed code to the server when your lead reminds you: “Hey, the Jira ID is missing!” In this situation, the natural reflex for many developers is to use git commit --amend. However, if the branch has already been shared with the team, this action changes the commit’s Hash. You’ll find yourself in a bind: forced to push --force and causing history conflicts (diverged branches) for all your colleagues.
In a real-world project with a team of five, we used to waste nearly two hours every week just resolving conflicts because members were amending old commits to add documentation links. Git Notes is the lifesaver. It’s like sticking a Post-it note on a gift box (the commit) without having to open the box or change the gift inside. The Hash remains the same, but the additional information is always fully displayed.
Key advantages of Git Notes:
- Preserve Hash IDs: Add or edit notes freely without worrying about Git history divergence.
- Clean Commit Messages: Keep your main messages concise by moving all metadata (Jira IDs, PR links, build logs) into Notes.
- Easy Automation: CI/CD systems can automatically log data to commits without interrupting the developer’s workflow.
Basic Git Notes Operations
This feature is built into the Git core; you don’t need to install any extra plugins. Here are the practical commands to apply to your project immediately.
1. Attaching notes to the latest commit
To quickly add a text snippet to the HEAD commit, use the command:
git notes add -m "Ticket-ID: IFZ-1234; Status: Approved by Lead"
2. Attaching information to any commit
If you want to add information to an older commit (e.g., hash 4f2a9b1), simply specify it directly:
git notes add -m "Thoroughly tested on Staging - Build #452" 4f2a9b1
3. How to view notes in history
When you run git log, Git automatically displays the Notes section at the end of each commit if they exist. Let’s check it out:
git log -n 1
The result is displayed clearly as follows:
commit 4f2a9b1c...
Author: ItFromZero <[email protected]>
Date: Thu May 7 10:00:00 2026 +0700
Feature: Add e-wallet payment functionality
Notes:
Ticket-ID: IFZ-1234; Status: Approved by Lead
Sharing Notes with the Team (Important Configuration)
Many people wonder: “Why did I add notes, but my colleagues can’t see them on GitHub?” In reality, Git Notes stay local by default. To share them, you need to configure refs/notes synchronization.
Pushing Notes to Remote
A standard git push ignores notes. You must specify them explicitly:
git push origin refs/notes/*
Automatically Fetching Notes
To avoid manual commands every time you pull code, add the following configuration to your .git/config file:
git config --add remote.origin.fetch "+refs/notes/*:refs/notes/*"
Now, every time you git fetch, all the team’s notes will be automatically pulled to your machine.
Advanced Application: Categorizing Notes (Namespaces)
A great tip is to divide Notes into different “compartments.” For example, one for Dev reviews and another for CI/CD bot deployment logs. This prevents data overlap.
# Notes for code review
git notes --ref review add -m "Need to optimize the loop at line 42" HEAD
# Notes for the build system
git notes --ref build add -m "Build-URL: http://ci.itfromzero.com/job/102" HEAD
To view these different types of notes simultaneously in the log, use:
git log --show-notes=review --show-notes=build
Integrating into Real-world CI/CD Workflows
In professional projects, I often set up scripts so Jenkins automatically records notes after a successful build. This allows developers to quickly check status without leaving the terminal.
# Example script in Jenkins
git notes --ref deployment add -m "Deployed to Prod at $(date)" $GIT_COMMIT
git push origin refs/notes/deployment
Regarding conflicts: since Notes are essentially a special branch, errors may occur if two people edit the same note simultaneously. The best approach is clear permission management: Developers only write to the review namespace, while Bots use deployment.
Git Notes is a “small but mighty” tool. It keeps your commit history clean while carrying a massive amount of metadata, making your team’s workflow much more professional.

