Skip to content

Instantly share code, notes, and snippets.

@Cassio8186
Forked from mort3za/git-auto-sign-commits.sh
Last active May 5, 2021 18:29
Show Gist options
  • Save Cassio8186/55ad8a590c63b8a563f6c18edf404249 to your computer and use it in GitHub Desktop.
Save Cassio8186/55ad8a590c63b8a563f6c18edf404249 to your computer and use it in GitHub Desktop.
Auto sign your git commits
# Generate new SSH Key
ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
# Test SSH connection to github
ssh -T git@github.com
# Generate a new pgp key: (better to use gpg2 instead of gpg in all below commands)
gpg --full-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
# See your gpg public key:
gpg --armor --export YOUR_KEY_ID
# YOUR_KEY_ID is the hash in front of `sec` in previous command. (for example sec 4096R/234FAA343232333 => key id is: 234FAA343232333)
# Set a gpg key for git:
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
# Delete keys
gpg --delete-key keyID1 keyID2 keyID3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment