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.
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
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!!!
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.
Android Studio 2.2.2
Gpg4win 2.3.3 (https://www.gpg4win.org/download.html)
Using variant "Gpg4win with GnuPG component only"
Git for Windows 2.10.1
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.
Related
I'm trying to enable commit signing on OS X Mojave.
git commit -S -am "Test"
The error is:
error: gpg failed to sign the data
fatal: failed to write commit object
What I tried:
gpg works fine (see below), did not install gpg1 or gpg2
Installed GPG KeyChain and added a new key (even added a separate sign-only subkey whithin)
Installed pinentry
gpg2 --clearsign works fine (generates a new .asc file for files, outputs text for plain text)
Questions I looked into and tried every option:
gpg failed to sign the data fatal: failed to write commit object [Git 2.10.0]
Git error - gpg failed to sign data
What am I doing wrong?
I also had this problem. I found a good solution.
Just try to sign a file before you commit.
$ touch a.txt
$ gpg --sign a.txt
Then, the OS will let you input the password.
If this step is OK, now you can commit by signing correctly.
I just added the key ID to the global config
list all keys:
gpg --list-keys
Select the one you added to github and set it.
git config --global user.signingkey [public key ID]
Heh, of course, right after I posted this question, I found the solution.
So my problem was that I followed this doc: https://help.github.com/en/articles/telling-git-about-your-signing-key
And set up both GPG and smimesign, when I have Git < 2.19 and no proper X.509 keys.
So I just removed the part with smimesign from global ~/.gitconfig
Try with echo "foobar" | gpg --clearsign. It should ask for your key's passphrase and return the signature.
If instead you see the following error message:
error: gpg failed to sign the data
fatal: failed to write commit object
You might want to try running export GPG_TTY=$(tty). If after testing again you're prompted for the password and it works, run this everytime on startup, adding it to ~/.bashrc, which is actually required according to gpg-agent's documentation, as mentioned in this dev.gnupg thread and which you can verify with man gpg-agent.
I also found this gitHub gist very useful.
To prompt you to enter a PIN or passphrase when required, install pinentry-mac
$ brew install pinentry-mac
$ echo "pinentry-program $(which pinentry-mac)" >> ~/.gnupg/gpg-agent.conf
$ killall gpg-agent
I'm using Git (and GitHub) on a daily basis and everything has been working fine and all of a sudden, I can no longer communicate with my remote GitHub repository through my Git commands. When I try to "Git pull", it gives the following error:
fatal: unable to access 'https://github.com/snahrvar/eatibl.git/':
error:1407742E:SSL routines:SSL23_GET_SERVER_HELLO:tlsv1 alert
protocol version
So, I tested across multiple repositories, and I get the same errors on my computer. I had someone else interact with those same repositories, and it works fine for them. Prior to this error, I did an "npm install sharp" on a project and that ended up failing, and I suspect this may have messed with some SSL setting, but that's a wild guess!
Any general thoughts or guidance would be much appreciated!
If it's helpful at all, here is my environment:
Git version: 1.9.4.msysgit.2
Windows version: Windows 8.1
Updating TortoiseGit and GCM didn't help me, but updating Git itself did, as per #Frederic's advice in comments.
https://git-scm.com/download/win
To make sure the new version of Git installs properly and doesn't conflict with previous installations (it might, if you used TortoiseGit's, because it would use different folders and mess with PATH variable), remove the existing Git installation before installing the updated Git. Might also need to install with administrator rights.
You're likely running into an incompatibility with GitHub's deprecation of weak SSL encryption protocols:
Weak cryptographic standards removal notice
The solution will vary, but for Windows you likely need to upgrade the Git credential manager to 1.14.0
https://github.com/Microsoft/Git-Credential-Manager-for-Windows/releases/tag/v1.14.0
If you are using Android Studio or IntelliJ IDEA, updating Git to the latest version and changing the path to point to the new version solve the problem for me.
Using TortoiseGit, I did all of the other fixes/updates given for this and still no success. I found this: Can't git push/pull/fetch suddenly
My TortoiseGit settings for Git for Windows Git.exe path was pointing to C:\Program Files (x86)\Git\bin. I changed it to C:\Program Files\Git\bin and now it's working again.
This is what worked for me.
Install the latest version of Git from here: https://git-scm.com/download/win
In TortoiseGit, go to menu Settings → General → Git.exe Path - change it from 32-bit to 64-bit path:
C:\Program Files (x86)\Git\bin → C:\Program Files\Git\bin
Updating Git was not enough in my situation. After debugging for several hours, this was my fix:
C:\wamp64\www\maandlastenmanager> git config http.sslVersion
tslv1.0
C:\wamp64\www\maandlastenmanager> git config http.sslVersion tlsv1.2
C:\wamp64\www\maandlastenmanager> git config http.sslVersion
tslv1.2
I had this same problem while pulling code from GitHub on my Visual Studio Code terminal. I found the advice in the previous answers useful and hacked a solution together following the steps below:
I updated Git.
I updated Git Credential Manager for Windows.
Made some changes to the registry.
Updated my Visual Studio Code installation to the latest version.
Changed my Windows path for Git from C:\Program Files (x86)\Git\bin. to C:\Program Files\Git\bin.
This repository was quite useful.
I hope this helps someone.
TL;DR: git config --system http.sslbackend schannel and switch off HTTPS checks for github.com in your antivirus software
I'm using the Git command line on Windows 8 x64. In addition, my antivirus software checks HTTPS traffic by default. Like other people in answering this question, I use GitHub almost daily.
Updating Git - didn't help - because I used OpenSSL (see below)
Updating credential manager - didn't help
Then I started playing with switching the SSL backend:
git config --system http.sslbackend openssl
----------------vs------------------
git config --system http.sslbackend schannel
and the antivirus software checks for SSL traffic:
OpenSSL, HTTPS checks ON: error:0407006A:rsa routines:RSA_padding_check_PKCS1_type_1:block type is not 01
OpenSSL, HTTPS checks OFF: SSL certificate problem: unable to get local issuer certificate
SecureChannel, HTTPS checks ON: schannel: next InitializeSecurityContext failed: Unknown error (0x80092012) - The revocation function was unable to check revocation for the certificate.
SecureChannel, HTTPS checks OFF: worked fine
P.S.: Instead of commandline, you can just reinstall the latest Git, selecting "Use native Windows SSL validation library".
P.P.S.: The case (3) seems to be a bug in the schannel library, because the MITM certificate my antivirus software uses is whitelisted on my machine.
On macOS, you can install the latest git via Homebrew.
Same for me with Git 1.9.5.msysgit.1 too. I tried to install https://github.com/Microsoft/Git-Credential-Manager-for-Windows/releases/tag/v1.14.0, but no change.
Actually, nothing happen after installation; maybe I'm doing something wrong? (That may not help for the initial question, but for other people, yes!)
Yeah, I encountered the same issue on a pull request today and the solution was to simply update Git by downloading the latest (2.16.2) 64-bit version of Git for Windows. It was released 5 days ago, on 2018-02-20.
The comment by #andw worked for me:
Update Git version 1.9.5 to 2.15.1 using these steps:
In sourceTree, go to menu Tools → Options → Git → Use Embedded Git.
A quick solution would be git config --global http.sslVerify true, but it is not recommended as it defeats the purpose using SSL.
A second and better way is to use ssh keys rather than an SSL URL.
Steps to generate SSH keys
o Run the following command in a Git terminal (Git Bash): ssh-keygen
After running the command, the following message will appear:
Generating public/private RSA key pair.
Enter file in which to save the key (/h//.ssh/id_rsa):
Give the path for the key to be stored in, for example, enter the file in which to save the key (/h//.ssh/id_rsa): C:\Users\Public\my-new-ssh-key
Then give the passphrase for that key (any password of minimum 8 characters)
• Next run the following command: eval “$(ssh-agent –s)”
• Run the following command: ssh-add C:/Users/Public/my-new-ssh-key Note: use forward slash in the path to the newly created SSH key.
After that, add the contents of the file my-new-ssh-key.pub and add it in the text area for Add public key (Bitbucket, GitHub, etc.)
While connecting to a remote repository to fetch, pull, push, etc., I had the same error:
fatal: unable to access 'https://github.com/repository.git/': error:1
407742E:SSL routines:SSL23_GET_SERVER_HELLO:tlsv1 alert protocol version
I just reinstalled Git 64-bit in place of 32-bit and that fixed the issue.
After installation, verify the Git path in environment variables. It should be:
C:\Program Files\Git\bin\git.exe
This is an issue with IntelliJ and RubyMine. GitHub must have disabled SSL (PCI compliance maybe?) in favor of TLS. If you open Settings in IntelliJ or RubyMine and navigate to Version Control > Git, you'll see it's using a git.exe installed under the application's path. You should download the most current version of Git and change the path in your VCS settings to point to that, e.g. C:\Program Files\Git\bin\git.exe if you install it on Windows. Works like a charm after that.
Sometimes, this is caused by outdated msysgit which is using old ssl and not maintained any more, you can install latest git for windows, and point the git.exe path in tortoise setting to it, then this problem gone.
Git version upgrade did the trick for me. I had the version 1.9.5 and so and I upgraded to 2.21.0 on windows. Also upgrading is very easy. We don't need to uninstall the older version. Download the latest Git installer and just keep on pressing next using default options and the version will be changed to new version and all the old settings will still be working like ssh keys etc. We don't need to generate the keys again and put on github or any other repository.
Earlier my https protocol cloning was not working and giving error
fatal: unable to access 'https://github.com/tensorflow/models/':
error:1407742E: SSL routines:SSL23_GET_SERVER_HELLO:tlsv1 alert
protocol version
Once I downloaded new version and ran the same clone command it worked without any issues.
I also came across to this problem recently
What worked for me was to revert an automatic update of git
Encountered a similar error.
On windows, Updated git on windows to the latest version.
That fixed the problem.
there is a similar question, but the difference here is that I am working on Windows. I am running git on Windows (working in git bash tool) and I have successefully cloned my forked repository. Now I need to make symbolic link and it gives me Permission denied. I can make new dir for example in .git folder and I have also set chmod /R 777 for .git directory, so it seems I have permissions.
I tried to run:
rm -rf hooks and then ln -s ../git_hooks hooks.
You might be running into a basic incompatibility of ln on windows platforms (in this case within MINGW-MSYS). You can replace ln with a version that "does the right thing" on Windows; have a look at this:
Git Bash Shell fails to create symbolic links
I had this issue on Windows and I did a couple of steps to resolve this :
Enabled core.symlinks by modifying git config
git config --edit
Opened Git Bash as an Administrator and executed the git checkout command
This worked for me, hope it helps someone.
If you have are using Git for Windows SDK, you can install winln using the pacman package manager by running: pacman -Su winln
Then you can run: winln -s target link, it will check that you have SeCreateSymbolicLinkPrivilege, otherwise it will fail. This is equivalent to running Window's mklink.exe.
I am surprise Git for Windows, does not ship with winln vs an ln command that does a copy without telling you that it did a copy.
When installing git-bash for windows, there is an option called "Enable symbolic links". When I installed git-bash with that option I had the same issue as OP. So I installed the same setup (git-bash) again with that "Enable symbolic links" option unchecked. Then my issue was resolved.
If you are using a local web server on Windows (OpenServer, Laragon, Local), then start the server as an administrator. It worked for me
I recently reinstalled Windows and I have a problem with downloading files from repository.
I have installed GIT and Python, but when I am trying to download anything from Bitbucket I get the message:
"fatal: could not read Password for: 'https://username#bitbucket.org': No such file or directory".
What am I doing wrong?
I solved it setting a global parameter:
git config --global core.askpass /usr/libexec/git-core/git-gui--askpass
Try to include your username and password in the URL like this:
git clone https://username:password#bitbucket.org/path_to/myRepo.git
I had the same problem an hour or so ago. My issue was that I was trying to do a git clone but using the https url instead of the ssh one. If you go to your repository you can select ssh or https from the dropdown for the clone url. Hope that helps!
Just solved this Problem
Git in Version 1.8.5.2 contains a but using bitbucket, updating my Git to Version 1.9.0 solved this problem.
I just tried to do the same thing and it did not work for me, and I too recently reinstalled windows on my machine.
I am used to checking out a private repo from my bitbucket account by using the simple command
git clone https://username#bitbucket.org/username/repo.git
and then being prompted to enter a password for my user.
It looks like this might be broken in version 1.8.5.2. I downgraded to version 1.8.4 and it started working as expected.
Git download list: http://code.google.com/p/msysgit/downloads/list
Hope this helps!
For https connections try installing the "Git Credential Store" (an "optional" step in the BitBucket tutorial).
This is how to install it:
Download git-credential-winstore.exe from http://gitcredentialstore.codeplex.com/
Open the Git Bash Shell and change the current directory to where git-credential-winstore.exe is located
Run ./git-credential-winstore -i /bin/git
Try to use git fetch in order to reenter and update the outdated password.
I had the similar issue. The cached password become invalid due to updating the actual password to new one. But git didn't ask me for reentering the valid password and just gave me an error that Authentication failed while I was trying to pull changes.
But magically, git asked me for the actual password when I typed git fetch instead of pulling the data. Once I entered the new password, apparently git updated the old one in its credentials storage and no longer asked me about the entering password again.
FIX IT (09/2020)
All the the answers here are wrong... You shouldn't NEVER do something like that:
https://username:PASSWORD#Bitbucket.org
SOLUTION
All you have to do is:
Go to Sourcetree -> Preferences -> Git
You will have the section "Git Version" with 2 options: Reset to ebedded Git and Use System Git
Sourcetree use the Ebedded git for default.
Click on "Use System Git" and.... Fixed!
Follow me on:
GIthub
Twitter
In my case, the problem was with the global file .gitconfig on Windows.
When I tried to use solution provided by #jsarroyo in Git BASH, I got an error saying that the file .gitconfig.lock did not exist. I could find no way to fix it.
When I completely removed .gitconfig, everything worked fine.
WARNING: This way, you lose all your git settings and you need to configure it again.
In your project go to .git/config and add after username :password
before : https://username#bitbucket.org/repo.git
afetr : https://username:password#bitbucket.org/repo.git
I had the same problem with the Android Studio Chipmunk 2021.2.1 Patch 2 integrated version control. Additionally I have BitBucket and GitHub ssh keys setup on my Windows PC. I was able to fix the issue by setting checked Use credential helper in File | Settings | Version Control | Git
In my case, it was just a wrong password for bitbucket entered into the prompt dialog. When I entered the correct password, the error disappeared.
If you are using android studio you might want to try enabling "Use credential helper".
Steps:
Go to File -> Settings -> Version control -> Git
Find "Use credential helper" option (mostly at bottom)
Enable this option by marking the checkbox before the option
I got this issue when I upgraded from Windows 7 to 8 and settings messed up for me too. I had to regenerate private and public keys, and change my TortoiseGIT to use plink, instead of SSH.exe
I wrote step by step instructions at http://techblog.saurabhkumar.com/2015/09/using-tortoisegit-on-windows-with.html
For Bitbucket If you are ok for the repo to be public you can just uncheck the "This is a private repository" checkbox in repo settings. Now a simple git clone should work.
On a mac mini with Mavericks I am having problems authenticating when I try to git clone from a private git server. I have installed and configured git on Windows and Ubuntu a few times with this same server and haven't this sort of problem before. I'm at a loss as to what to try next.
Symptoms:
git clone https://username#git.example.com:8448/git/libs/project.git
Cloning into 'project' ...
Password for 'https://username#git.example.com:8448': [1] note
fatal: Authentication failed for 'https://username#git.example.com:8448/git/libs/project.git'
[1] I am not asked for this on other systems. I believe I have configured my git client to not ask for passwords. No password I provide is good at this prompt
I have this in my ~/.gitconfig:
[http]
sslKey = /Users/macuser/auth/username.key
sslCert = /Users/macuser/auth/username.pem
sslVerify = false
[user]
name = username
email = username#example.com
I received the following files when setting up my client certificates which I placed in a folder named ~/auth:
username.cer
username.p12
username.pem
ca.cer
I ran this command to generate the key file:
openssl rsa -in /Users/macuser/auth/username.pem -out /Users/macuser/auth/username.key
And then I ran git config commands such as:
git config --global http.sslKey /Users/macuser/auth/username.key
git config --global http.sslCert /Users/macuser/auth/username.pem
git config --global http.sslVerify false
After configuring git just like the steps above, on other systems when I do a 'git clone https' it just works. On OS X Mavericks with Xcode command line tools installed, git cannot authenticate.
What am I doing wrong?
Thanks in advance.
Edit:
I thought I'd add this piece of information. The server is using a self signed certificate, or one which comes from no authority. This is why I set http.sslVerify to false.
Here are the verbose clone commands. The setups on Linux and Mac are the same, save for auth folder locations. The Linux version succeeds while the Mac version fails.
http://cache.codebot.org/stackoverflow/linux-git-works.txt
http://cache.codebot.org/stackoverflow/mac-git-fails.txt
Answer:
sudo port install git-core
when you try to use git clone and if its prompt for password please provide the git personal access token here
that will resolve the issue.
The solution was to use the macports version of git rather than using the version included with Xcode command line tools.
sudo port install git-core
sslVerify false? Then you desactivate completely the certificate verification by curl.
You can have more details with:
GIT_CURL_VERBOSE=1 git clone https://...
Check if the other systems don't have a %HOME%/_netrc (Windows) or ~/.netrc (unix) with your credentials in it, which would explain why you don't have to enter a password there.
In your case, it is possible the CA and other root certificates used in Linux in /etc/ssl/certs/ca-certificates.crt aren't present on mac.
Try to add the content of that Linux file to the git cert file on the client side on your <path/to/git/bin/curl-ca-bundle.crt> file, a bit like in this solution.
The OP sysrpl reports though that it isn't necessary, since sysrpl had to do a:
sudo port install git-core
to update/reset the git installation on the Mac.