Skip to content

Instantly share code, notes, and snippets.

@paolocarrasco
Forked from mort3za/git-auto-sign-commits.sh
Last active October 11, 2022 11:44
Show Gist options
  • Save paolocarrasco/ab6244b16c942514db18962a24b257fe to your computer and use it in GitHub Desktop.
Save paolocarrasco/ab6244b16c942514db18962a24b257fe to your computer and use it in GitHub Desktop.
Auto sign your git commits
# Generate a new pgp key: (better to use gpg2 instead of gpg in all below commands)
gpg --gen-key
# maybe you need some random work in your OS to generate a key. so run this command: `find ./* /home/username -type d | xargs grep some_random_string > /dev/null`
# check current keys:
gpg --list-secret-keys --keyid-format LONG
# Set a gpg key for git (from previous step... the key_id is after the slash):
git config --global user.signingkey your_key_id
# To sign a single commit:
git commit -S -a -m "Test a signed commit"
# Auto-sign all commits globaly
git config --global commit.gpgsign true
# Also it's better to use gpg2 instead of gpg in above commands. In this case, you should set gpg2 as default program for gpg in git, To do this:
git config --global gpg.program gpg2
@Khazbs
Copy link

Khazbs commented Oct 11, 2022

Don't forget to gpg --armor --export YOUR_KEY_ID and pass the public key block to whoever needs to verify your signature

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment