WalzoneInterview Prep
📞 Interviewing soon? Practice with a realistic AI mock phone interview — it calls you, then scores you. First 15 min FREE →

Git · Advanced · question 54 of 100

Can you explain the purpose of ’git notes’, and how do you use them?

📕 Buy this interview preparation book: 100 Git questions & answers — PDF + EPUB for $5

Git notes are a way to attach additional information or annotations to a Git commit without modifying the commit itself. This can be useful for adding context or metadata to a commit, such as tracking issue numbers or recording review comments.

To create a note for a commit, you can use the git notes add command followed by the commit hash:

    git notes add <commit-hash>

This will open your default text editor, allowing you to enter the note content. Once you save and close the editor, the note will be created and associated with the specified commit.

To view the notes for a particular commit, you can use the git notes show command:

    git notes show <commit-hash>

By default, this will display the notes in your terminal. You can also use the –ref option to specify a particular notes ref (which defaults to refs/notes/commits) if you have multiple notes refs in your repository.

You can also edit or delete existing notes using the git notes edit and git notes remove commands, respectively.

One important thing to note (no pun intended) is that notes are not included in the default output of commands like git log. To include notes in the output, you can use the –show-notes option:

    git log --show-notes=<notes-ref>

This will display the notes for each commit in addition to the normal log output.

Overall, Git notes can be a powerful tool for adding extra information to your commit history in a non-destructive way. However, they should be used judiciously and with care, as they can add complexity and potential confusion to your repository if overused.

Reading is step one. Saying it out loud is the interview. Our AI interviewer calls your phone and runs a realistic Git interview — then scores it.
📞 Practice Git — free 15 min
📕 Buy this interview preparation book: 100 Git questions & answers — PDF + EPUB for $5

All 100 Git questions · All topics