无法通过 Android Studio 推送到 git?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/22614715/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Can't push to git via Android studio?
提问by AruLNadhaN
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
我通过 Android Studio 从 Github 克隆了一个存储库。我对代码进行了一些更改,然后毫无问题地提交和推送。今天,我对代码进行了一些更改。我承诺了他们,但是当我试图推动他们时,它说
Can't push, because no remotes are defined
无法推送,因为没有定义遥控器
Thanks for your help..
谢谢你的帮助..
回答by Wes Eklund
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:
显然没有办法从 IDE 中做到这一点,一定是某些错误删除了您的遥控器。如果您在项目文件夹中的 .git 目录中打开配置文件,请转到底部并插入:
[remote "origin"]
url = https://github.com/YOURPROFILE/YOURREPO.git
回答by mshutov
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_remoteand removing origin. So I got smth like that:
也许,回答晚了,但我昨天在 IDEA 中遇到了相关问题。我为每个模块都有单独的存储库,当我最初将它们检出到本地存储库时,所有遥控器都被称为origin。昨天我更改了某些模块的遥控器,但不是通过替换 - 通过添加new_remote和删除origin。所以我得到了这样的东西:
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 definedevery 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 originfor modules to new_remote. As I understant you can have smth like this:
从那一刻起,我收到错误无法推送,因为每次尝试推送时都没有定义遥控器。在 git bash 中一切正常,但在 IDEA 中则不然。我花了一整天的时间,晚上我尝试了最后一个解决方案,它奏效了 -我将所有本地存储库更改为具有相同名称的 remotes。就我而言,我改名为原点的模块new_remote。正如我所理解的,你可以像这样:
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.
但是在这种情况下,从 Intellij 本机插件中,您将只能推送到 {origin->[master]},因为只有这个远程/分支对对于在此项目存储库中注册的所有内容都是通用的。
ALso, it seems that this limitation wil be fixed in later versions. - https://youtrack.jetbrains.com/issue/IDEA-81620
此外,似乎此限制将在以后的版本中修复。- https://youtrack.jetbrains.com/issue/IDEA-81620