Skip to content

Instantly share code, notes, and snippets.

@mort3za
Last active May 1, 2026 14:38
Show Gist options
  • Select an option

  • Save mort3za/ad545d47dd2b54970c102fe39912f305 to your computer and use it in GitHub Desktop.

Select an option

Save mort3za/ad545d47dd2b54970c102fe39912f305 to your computer and use it in GitHub Desktop.

Revisions

  1. mort3za revised this gist Jun 5, 2019. 1 changed file with 7 additions and 7 deletions.
    14 changes: 7 additions & 7 deletions git-auto-sign-commits.sh
    Original file line number Diff line number Diff line change
    @@ -1,19 +1,19 @@
    # generate a new pgp key: (better to use gpg2 instead of gpg)
    # 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

    # export public key in gpg:
    gpg --armor --export your_key_id
    # your_key_id is the HASH id in front of `sec` in previous command. (for example sec 4096R/234FAA343232333 => key id is: 234FAA343232333)
    # 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 pgp key for git:
    # Set a gpg key for git:
    git config --global user.signingkey your_key_id

    # sign your single commit:
    # To sign a single commit:
    git commit -S -a -m "Test a signed commit"

    # auto sign your commits globaly
    # Auto-sign all commits globaly
    git config --global commit.gpgsign true
  2. mort3za revised this gist May 27, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion git-auto-sign-commits.sh
    Original file line number Diff line number Diff line change
    @@ -7,7 +7,7 @@ gpg --list-secret-keys --keyid-format LONG

    # export public key in gpg:
    gpg --armor --export your_key_id
    # your_key_id is the HASH id in front of `sec` in previous command.
    # your_key_id is the HASH id in front of `sec` in previous command. (for example sec 4096R/234FAA343232333 => key id is: 234FAA343232333)

    # set a pgp key for git:
    git config --global user.signingkey your_key_id
  3. mort3za revised this gist May 27, 2019. 1 changed file with 0 additions and 3 deletions.
    3 changes: 0 additions & 3 deletions git-auto-sign-commits.sh
    Original file line number Diff line number Diff line change
    @@ -5,9 +5,6 @@ gpg --gen-key
    # check current keys:
    gpg --list-secret-keys --keyid-format LONG

    # export private key in gpg:
    gpg --export-secret-key -a "your_username"

    # export public key in gpg:
    gpg --armor --export your_key_id
    # your_key_id is the HASH id in front of `sec` in previous command.
  4. mort3za revised this gist Jan 13, 2018. 1 changed file with 4 additions and 4 deletions.
    8 changes: 4 additions & 4 deletions git-auto-sign-commits.sh
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,7 @@
    # generate a new pgp key: (better to use gpg2 instead of gpg)
    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

    @@ -8,10 +12,6 @@ gpg --export-secret-key -a "your_username"
    gpg --armor --export your_key_id
    # your_key_id is the HASH id in front of `sec` in previous command.

    # generate a new pgp key:
    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`

    # set a pgp key for git:
    git config --global user.signingkey your_key_id

  5. mort3za revised this gist Jan 13, 2018. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions git-auto-sign-commits.sh
    Original file line number Diff line number Diff line change
    @@ -6,6 +6,7 @@ gpg --export-secret-key -a "your_username"

    # export public key in gpg:
    gpg --armor --export your_key_id
    # your_key_id is the HASH id in front of `sec` in previous command.

    # generate a new pgp key:
    gpg --gen-key
  6. mort3za created this gist Oct 11, 2017.
    21 changes: 21 additions & 0 deletions git-auto-sign-commits.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,21 @@
    # check current keys:
    gpg --list-secret-keys --keyid-format LONG

    # export private key in gpg:
    gpg --export-secret-key -a "your_username"

    # export public key in gpg:
    gpg --armor --export your_key_id

    # generate a new pgp key:
    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`

    # set a pgp key for git:
    git config --global user.signingkey your_key_id

    # sign your single commit:
    git commit -S -a -m "Test a signed commit"

    # auto sign your commits globaly
    git config --global commit.gpgsign true