avatar
4 minutes read

Why use git notes?

Git notes offer a powerful way to add extra metadata to commits, providing flexibility to enhance commit history with additional information.

Use Cases:

  • Bug tracking information: Link to bug reports or issue trackers.
  • Test results: Record test outcomes for specific commits.
  • Deployment information: Note deployment environments and dates.
  • Code review comments: Capture feedback from code reviews.
  • Custom metadata: Store any relevant data associated with a commit.

Best Practices:

  • Consistency: Establish a consistent naming convention for notes to improve searchability.
  • Clarity: Write clear and concise notes to provide value.
  • Regular Updates: Keep notes up-to-date as the project progresses.
  • Version Control: Treat notes as part of your project's history and commit them regularly.
  • Integration: Consider integrating notes with your CI/CD pipeline for automated updates.

Example :

Create a note

git notes add -m "Bug #123 fixed" HEAD

View notes

git log --notes

Edit a note

git notes edit HEAD

Delete a note

git notes remove HEAD

Advanced Usage:

  • Note refs: Create multiple note refs for different types of notes (e.g., bugs, tests).
  • Note merging: Merge notes from different branches using  "git notes merge" .
  • Note filtering: Use "git notes filter"  to extract specific notes.

Comments