brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: git notes adds a remark to a commit without changing the commit

Git
~/tips/tip-git-notes-add

git notes add -m 'Tested on Debian 13' 72a144e2

Attaches extra text to an existing commit, shown in git log, without rewriting history.

Commits cannot be changed without getting a new hash. So when I want to add something after the fact, like “this one was tested” or a link to the issue, a note is the polite way.

git notes add -m 'Tested on Debian 13' 72a144e2

Leave out the commit ID and the note goes on HEAD. The docs say notes are shown by git log along with the original commit message, and the commit hash stays exactly the same.

The docs say notes are stored in a separate ref, refs/notes/commits by default. That is why they can be added later without touching the commit.

Where I’d use it: marking which commit was deployed, adding review remarks to someone else’s commit, or noting why a commit was reverted, all without a history rewrite that forces everyone to pull again.

Caveat: because notes live in their own ref, they do not travel with your branches in the same way. I would not assume a colleague or a CI system sees them until I have checked how that remote and that clone handle refs/notes. For something everyone must see, the commit message or the pull request is the safer place.

Further reading: git-notes documentation

More Git tips git show-branch main feature git log --stat -5 git merge --no-ff feature -m "Merge feature" git merge --squash feature git merge --abort All Git tips (144) All topics

Link