I'm interested on having each of my commits signed with my GPG key. Since I use magit for interfacing with git, I was wondering if telling magit to sign each commit was possible (or some workaround to achieve this was feasible, at least).

  • Does Git even support commit signing? I thought only tags could be signed…
    – user227
    Commented Dec 1, 2015 at 6:39
  • 1
    @lunaryorn git commit -S[<keyid>], --gpg-sign[=<keyid>]. There is at least one reason to sign each commit: to have stronger evidence that the commit came from the person you think it did. Signing tags only allows you to detect history changes.
    – Nsukami _
    Commented Dec 1, 2015 at 7:03
  • @Nsukami_That does not answer my question, does it?
    – user227
    Commented Dec 1, 2015 at 7:08
  • 1
    @lunaryorn Sorry if it doesn't answer your question. Yes, Git support commit signing
    – Nsukami _
    Commented Dec 1, 2015 at 9:43

2 Answers 2


In Magit commits are created using the committing popup (c). That popup would therefore be a good place to start looking for gpg support. If you do that, then you will find this:

=S Sign using gpg (--gpg-sign=)

So type = S and the select a key. To avoid having to do that every time you create a commit you can save the value of that argument (and all other currently set arguments) using C-x C-s.

You might still have to type the passphrase every time. To avoid that you should start a gpg-agent and make sure Emacs knows about it, e.g. using the keychain shell script and the keychain-environment Emacs package.

Also see and set the --show-signature argument in the logging popup.

  • 3
    Has this been changed in transient? Commented May 12, 2019 at 17:05
  • 7
    This argument is now hidden by default. The transient announcement explains how to show it by changing the "level".
    – tarsius
    Commented May 12, 2019 at 21:50
  • 6
    In case anyone stumbles here looking: magit.vc/manual/transient/Enabling-and-Disabling-Suffixes.html Commented May 13, 2019 at 6:10
  • @tarsius I don't seem to be able to change the level. How do I set about doing that? Thank you.
    – e18r
    Commented Jun 20, 2019 at 17:28
  • 1
    Which part of the documentation that tejasbubane linked to is unclear?
    – tarsius
    Commented Jun 20, 2019 at 19:36

Try this in your $HOME/.gitconfig or your .git/config

    email = YourEmail
    name = YourName
    signingkey = XXXXXXXX
    gpgsign = true

Then just commit as usual.

  • 1
    This answer has the advantage that you can set a key per repository. It seems that magit's =S option sets the key in $HOME/.gitconfig, so the same for all your repositories.
    – ph0t0nix
    Commented Sep 12, 2018 at 8:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.