Home » Android » Can't push to git via Android studio?

Can't push to git via Android studio?

Posted by: admin June 15, 2020 Leave a comment

Questions:

I cloned a Repository from Github via Android Studio. I made some changes to the code, then committed & pushed without a problem. Today, I made some changes to the code. I committed them but when I tried to push them it says

Can’t push, because no remotes are defined

enter image description here
Thanks for your help..

How to&Answers:

Apparently there’s no way to do it from the IDE, some bug must have deleted your remote. If you open up the config file in your .git directory within your project folder, goto the bottom and insert:

[remote "origin"]
url = https://github.com/YOURPROFILE/YOURREPO.git

Answer:

Maybe, it is late to answer, but I got related problem yesterday in IDEA.
I have separate repository for each module and when I initially checkout them into local repository all remotes were called origin. Yesterday I changed remotes for some modules but not by replacing – by adding new_remote and removing origin. So I got smth like that:

module_1 -> {new_remote/master}
module_2 -> {origin/master}
module_3 -> {origin/master}
...
module_n -> {new_remote/master}

From that moment I received error Can’t push, because no remotes are defined every time I tried to push. In git bash all worked fine, but not in IDEA. I spent whole day and at evening I tried last solution and it worked – I changed all local repositories to have identically named remotes. In my case, I renamed origin for modules to new_remote.
As I understant you can have smth like this:

module_1 -> {origin->[master, test], staging->[master]}
module_2 -> {origin->[master], staging->[master]}
module_3 -> {origin->[master, test]}

But from Intellij native plugins in this case you will be able to push only to {origin->[master]}, because only this remote/branch pair is common to all registered in this project repositories.

ALso, it seems that this limitation wil be fixed in later versions. – https://youtrack.jetbrains.com/issue/IDEA-81620