Android Studio - Push failed: fatal: Could not read from remote repository
Solution 1
This is probably an Intellij problem. Your key are managed natively by ssh, and Intellij has it's own ssh program.
Go to the settings, search git->ssh executable then choose native
As seen here : git with IntelliJ IDEA: Could not read from remote repository
Solution 2
Go to Settings > Version Control > Git. Make sure SSH executable is set to “Native.”
If it's already set, switch back to “Built-in,” apply it, and then again switch back to “Native".
Solution 3
There is two ways for Git SSH verification in Android Studio or IntelliJ, changing via: settings - Version Control - Git - SSH excuteable - "Built-in" or "Native"
- Built-in : means using ssh key pair built in Git for authentication.
you can generate it via
ssh-keygen -t rsa
the default saved path is "~/.ssh/id_rsa" and "~/.ssh/id_rsa.pub". You should add the Public key in your BitBucket account. the path like : manage account - SSH keys - add keys - Native : means using the ssh pair generated by the native repository hosting service, such as BitBucket or GitHub, which is often auto-add in the service account. For example in GitHub. It generated a pair of SSH key, "~/.ssh/github_rsa.pub" and "~/.ssh/github_rsa" and the Public key has been auto-added in my account via GitHub GUI maybe. So change the SSH executable to "Native" could be a simple way.
Anyway, you can use the both way after you add the correct Public key in you acoount in repository hosting service.
Solution 4
Despite my SSH-executable was set to Native
I was getting that error because I have set password for SSH key file.
I haven't found the way how to specify password in Android studio but there is another solution, you can remove password which can be done with $ ssh-keygen -p
. Then just confirm file location, enter your old password and leave new password blank.
Taken from How do I remove the passphrase for the SSH key without having to create a new key?
Solution 5
Another solution that helped me was "Use credential helper".
Michel Feinstein
8+ years of experience as a Software Engineer, 3 years building Flutter Applications, 6 years building Android Applications. Worked with many different technologies, such as Mobile Apps, Serverless Applications, Micro-Services, Desktop Apps, Robotics, Embedded Systems, IoT, and others. Managed projects from start to finish, with clients in Brazil, Canada, and Israel. Advanced experience with Dart, Java, C#, C, C++, and SQL, moderate experience with Javascript. If you want to see some of my work, here are some public projects I have done or contributed to. Feel free to contact me over LinkedIn.
Updated on July 08, 2022Comments
-
Michel Feinstein almost 2 years
I have a git project at Android Studio and a remote at BitBucket and I changed it to use SSH instead of HTTPS. I can make everything work using Atlassian's SourceTree, but in Android Studio every time I try to push the project it says
Push failed: fatal: Could not read from remote repository.
Does anyone have a clue about what could be happening?