If you have git for Windows installed, and selected MingGW option during setup, this is what I used to get Android Studio working with signing commits.
Programs mentioned/used with links for those who don't have them yet.
For those who wants to read the article I used to get gpg signing working in my Windows environment (The bottom half of the page starting with the git config
lines are what we're more concerned with):
https://jamesmckay.net/2016/02/signing-git-commits-with-gpg-on-windows/
I'll briefly walk through the process for doing the gpg portion via command line - presuming that all three programs are installed already from here on in.
Check Git setting in Android Studio
If you haven't specified where git is in Android Studio, here's where you do it in Settings:
NOTE: This can be done either in File > Project Settings
for one project or File > Other Settings > Default Settings...
Version Control > Git > Path to Git Executable
Since I was using the MinGW version, it's set to:
C:\Program Files\Git\mingw64\bin\git.exe
Export existing public and secret keys from MinGW version (git bash)
NOTE: Execute using MinGW prompt program
gpg --export > ~/gpg-public
gpg --export-secret-keys > ~/gpg-secret
NOTE: For those who don't know, ~/
is by default set to your user's home directory. (e.g. Windows 10: C:/Users/%USERNAME%
)
Import exported keys into Gpg4win
NOTE: Execute using Windows Command Prompt.
gpg --import < "C:/Users/%USERNAME%/gpg-public"
gpg --import < "C:/Users/%USERNAME%/gpg-secret"
Replace the location with wherever your gpg-public
and gpg-secret
files are.
Make git use gpg from Gpg4win
As mentioned in the article. It's reposted here if you didn't open it.
NOTE: Execute using MinGW prompt program
git config --global gpg.program "C:/Program Files (x86)/GNU/GnuPG/gpg2.exe"
Replace the gpg.program
value (keeping the gpg2.exe
) above with wherever you specified the gpg4win installer to install it to.
(OPTIONAL) While you're at it, you can configure your git to auto sign your commits with a default key (git version >= 2.0 required)
git config --global user.name <name>
git config --global user.email <email>
git config --global user.signingkey <your-key-ID>
git config --global commit.gpgsign true
Replace the values in < >
with your own. You can get the key ID by running gpg --list-keys
and taking the ID from the line starting with pub
and after the /
.
Now you should be able to commit using Android Studio and see a prompt come up for the password entry.