8

Git pushes can be signed with

git push --signed

Is it possible to specify with which gpg key to sign the push? The manpage of git push does not specify anything and looking through the configuration options there only seems to be

user.signingkey

to specify the signing key for signed commits.

Thomas
  • 2,093
  • 3
  • 23
  • 28
  • Make sure to use Git 2.19 (Q3 2018), especially if you are using HTTPS: https://stackoverflow.com/a/51110396/6309 – VonC Jun 29 '18 at 23:11

1 Answers1

1

No simple switch solution, sadly...

But maybe you might be happy creating an alias for signed commits, such as:

$ git config --global alias.ptest '!git config user.signingkey KEY && git push --signed'
$ git config --global alias.pdev '!git config user.signingkey KEY2 && git push --signed'

Arguments should be passed to the push without issues.

petrpulc
  • 940
  • 6
  • 22
  • Apparently, changing the environment variable for user and email may be enough. In https://github.com/git/git/blob/master/gpg-interface.c#L145 if no key is specified in config, the user identity is used. So, try creating keys with some user name and email and push with modified `GIT_COMMITTER_NAME` and `GIT_COMMITTER_EMAIL` – petrpulc Sep 11 '17 at 13:19