Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I pass --homedir to git when signing using GPG?

Tags:

git

linux

gnupg

I have a custom location where I have my GPG keys, which is different from the default ~/.gnupg directory.

I need to sign a git commit using GPG, but I can't find any option to specify the custom location to Git: it always searches in the default one.

Is there an option for this? I tried modifying:

program = /usr/bin/gpg --homedir ~/.mygnupg in the .git/config file but no luck!

like image 793
El Mostafa IDRASSI Avatar asked Oct 28 '25 05:10

El Mostafa IDRASSI


1 Answers

You should be able to use the GNUPGHOME environment variable:

GNUPGHOME=~/.mygnupg git commit ...

You can also set this variable in your ~/.profile or ~/.bash_profile if you want it to always be set to that value.

like image 88
Chris Avatar answered Oct 29 '25 19:10

Chris



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!