Can't push to git via Android studio?

孤者浪人 提交于 2019-12-10 03:30:46

问题


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

Thanks for your help..

回答1:


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



回答2:


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



来源:https://stackoverflow.com/questions/22614715/cant-push-to-git-via-android-studio

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!