🔀 Git & GitHub Intermediate

What is git notes?

Why Interviewers Ask This

Candidates at the intermediate level are expected to not only know this concept but explain the trade-offs involved. Interviewers use this question to see if you can reason about design decisions, not just recall facts.

Answer

Git notes allow you to attach additional information to commits without altering the commit itself (preserving the SHA). Notes are stored separately from commits in refs/notes/commits. Usage: git notes add -m "Reviewed by Alice" abc1234 — add a note to a commit; git notes show abc1234 — show note for a commit; git log --show-notes — include notes in log output; git notes edit abc1234 — edit a note; git notes remove abc1234 — remove a note. Notes are not pushed by default: git push origin refs/notes/commits — push notes; git fetch origin refs/notes/commits:refs/notes/commits — fetch notes. In ~/.gitconfig: [notes] displayRef = refs/notes/* to auto-display. Use cases: (1) Add build metadata to commits without changing them; (2) Attach code review results; (3) CI systems annotate commits with test results; (4) Link external ticket IDs to historical commits. Git notes are less commonly used than commit messages but are useful when you need to annotate commits after the fact (e.g., add CVE references to old security commits) without rewriting history.

Pro Tip

Demonstrate both theoretical understanding and practical experience. Say what it is, then give an example of how you actually used it in a Git & GitHub codebase.