Git notes are a feature to add meta-information to Git objects. See this Stackoverflow article for further details. Similar to commits, I also want to sign notes.
My local Git is configured to sign all commits. While signing Git commits works as expected, Git notes remain unsigned. In my local Git config I have the following:
# excerpt from ~/.gitconfig
[commit]
gpgsign = true
In order to sign notes, I tried the following.
# Create example repo
git init repo
cd repo
date >> DATE && git add DATE && git commit -m "update date"
# Commit has been signed (OK)
git show $( git rev-parse HEAD ) --show-signature
git notes add -m "Example note"
# Commit has a note now (OK)
git show $( git rev-parse HEAD ) --show-signature
# Note has not been signed (fail)
git log -p notes/commits --show-signature
How can I accomplish that the Git notes are signed, too?
Git does not natively support GPG signing notes.
However, you can manually sign notes as GPG clearsigned documents.
You can create a clearsigned note as
which will look something like this
You can then verify the signature with gpg as
To extract just the note, you can use