How to add a note to a commit with git notes command

Published on Aug. 22, 2023, 12:13 p.m.

When you change a part in Git, you can add a message with it.This message is basically a note that you can add to the commit.

However, sometimes, you may want to add additional notes to the commit.

Git Notes

You can do so using git notes command.

$ git notes add -m "Deleted script.html because it was no longer needed" f0a40dfff6582a516dd47d4bde8831b45e4ec40d

Now, when you run the git log command, you’ll see the note added to the commit .

➜  test git:(master) git log
commit f0a40dfff6582a516dd47d4bde8831b45e4ec40d (HEAD -> master)
Author: Amit Merchant 
Date:   Sun Jan 1 18:48:30 2023 +0530

    deleted a file

Notes:
    Deleted script.html because it was no longer needed

Update a note

In any case, if you want to update the note, you can do so command like so.

git notes add -f -m "Version 2 of the note" f0a40dfff6582a516dd47d4bde8831b45e4ec40d