Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Studio and Git - How do I GPG-sign my commits?

Tags:

According to this link, I simply need to include the -S switch to sign my commit using my GPG key, but I don't see how I can use that in Android Studio.

How do I sign my commits in Android Studio?

EDIT: I appreciate that OSX solutions are coming along, but I'd really like to see an answer that works with Windows. I only use my Mac for documents and stuff.

like image 783
Aloha Avatar asked Jun 11 '16 07:06

Aloha


2 Answers

As I mentioned in "Sign git commits with GPG", with Git 2.0:

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.

This doesn't fully work though, and is followed by issue 127802, with the following workarounds:

Created a helper script with that content:

/usr/bin/gpg –batch –no-tty "$@" 

and set gpg.program to that script

Or:

Adding "no-tty" to "~/.gnupg/gpg.conf" solved the problem for me.

You might still get the error message:

Commit failed with error: gpg: problem with the agent - disabling agent use gpg: Sorry, no terminal at all requested - can't get input error: gpg failed to sign the data fatal: failed to write commit object 

Again: bug in progress, also followed by issue 110261:

resolve it with this in addition to the previous solution (OS X):

1) brew install gnupg gnupg2 pinentry-mac

2) nano ~/.gnupg/gpg-agent.conf -> pinentry-program /usr/local/bin/pinentry-mac

3) git config -–global gpg.program gpg2

like image 93
VonC Avatar answered Sep 28 '22 11:09

VonC


After make some test I follow this steps and it works Please remember to restart the Android Studio after follow this steps:

Are you tired off write the password for each commit???

  • Follow the link: https://github.com/pstadler/keybase-gpg-github

  • after that edit the gpg.conf

nano ~/.gnupg/gpg.conf

add the following lines

use-agent no-tty default-key <your key id> 
  • after made all the configuration and if you use MacOS. You should:

ln -s /usr/local/Cellar/libgcrypt/1.7.0_1 /usr/local/opt/libgcrypt

ln -s /usr/local/Cellar/libgpg-error/1.22 /usr/local/opt/libgpg-error

ln -s /usr/local/Cellar/libassuan/2.4.2 /usr/local/opt/libassuan

ln -s /usr/local/Cellar/pth/2.0.7 /usr/local/opt/pth

  • execute

source ~/.profile

  • make one commit using the option -S

git commit -am "my commit message" -S

  • you should get a password promp. -- put your password

Thats it!!!

like image 29
Darien Alvarez Avatar answered Sep 28 '22 11:09

Darien Alvarez