Sign git commits with GPG

Is there a way to sign git commits with gpg? It’s so easy with tags (using -s instead of -a), it seems there would be a similar function for commits.

  • ZSH prompt not showing git unstaged files
  • How do you set the 16 Terminal Colors for Git-Bash?
  • How can I push git-replace to a remote repo?
  • Using Git in R-studio: cannot stage modified code files
  • Git, find out which files have had the most commits
  • GitLab, Redmine integration issues - Bitnami stack on different machines
  • git merge: Removing files I want to keep!
  • Web interface to versioning system
  • git fetch with path instead of remote
  • get list of git branches for a repo hosted on github
  • On Mac, where can I find git-http-backend?
  • How to setup gitblit in windows
  • 2 Solutions collect form web for “Sign git commits with GPG”

    git commit -S (requires git >= 1.7.9).

    Note: Adding the -S option all the time can be cumbersome.
    In git 2.0 and later, you can add a config which will take care of that option for you.

    See commit 2af2ef3 by Nicolas Vigier (boklm):

    Add the commit.gpgsign option to sign all commits

    If you want to GPG sign all your commits, you have to add the -S option all the time.
    The commit.gpgsign config option allows to sign all commits automatically.

    commit.gpgsign
    

    A boolean to specify whether all commits should be GPG signed.
    Use of this option when doing operations such as rebase can result in a large number of commits being signed. It may be convenient to use an agent to avoid typing your GPG passphrase several times.

    As Apteryx commented below:

    To set this globally on the command line:

    git config --global commit.gpgsign true
    
    Git Baby is a git and github fan, let's start git clone.