[英]How to push an Android Studio Project to a remote GitLab Repository
I am coming from the eclipse/svn world and for a new android project with android studio I decided it might be a good time to learn more about GIT. 我来自eclipse / svn世界和android工作室的一个新的android项目,我认为这可能是了解更多关于GIT的好时机。 After some research I decided to install GitLab on my server in the same network, since it seems to perfectly fit my needs and I prefer to have the data on my server.
经过一番研究后,我决定在同一网络中的服务器上安装GitLab ,因为它似乎完全符合我的需求,我更喜欢在我的服务器上安装数据。 The installation was done fast and I was able to connect to the webinterface on the server from my local machine.
安装快速完成,我能够从本地计算机连接到服务器上的Web界面。
Now I wanted to push a prototype in form of an android project to my GitLab
Repository on the server. 现在我想将一个android项目形式的原型推送到服务器上的
GitLab
Repository。 Here I started getting confused on how to start. 在这里,我开始对如何开始感到困惑。
First I installed GIT on my local machine and enabled it in my android studio project, and succeded to commit files (eventhough I wasn't really sure, where these files get commited to,.. does enabling git create a local repository for that project?). 首先我在我的本地机器上安装了GIT并在我的android studio项目中启用它,并成功提交文件(虽然我不太确定,这些文件被提交到哪里,...确实启用git为该项目创建本地存储库?)。
Ok, next I of course want these committed files to end up in a Repository of my GitLab
remote server. 好的,接下来我当然希望这些提交的文件最终存放在我的
GitLab
远程服务器的存储库中。 I found this topic but unfortunately I did not understand how to exactly add my server as a remote host. 我找到了这个主题,但不幸的是我不明白如何将我的服务器完全添加为远程主机。
I tried using gitbash
and used 我尝试使用
gitbash
并使用
git remote add origin https://[serverip]:[gitlabport]
but this did not seem to change anything. 但这似乎没有任何改变。 Whenever I commit (also tried commit and push) from UI there was no new repository on my GitLab Web Interface.
每当我从UI提交(也尝试提交和推送)时,我的GitLab Web界面上都没有新的存储库。
Using gitbash to push as suggested by Makoto with 使用gitbash推送Makoto建议
git push -u origin master
reveals the following error: 揭示以下错误:
"fatal: 'https://[serverip]:[gitlabport]/info/refs not valid: is this a git repository?
So I guess I need to let git remote add
point to an already existing repository? 所以我想我需要让
git remote add
指向已经存在的存储库? And why does the Android Studio UI not reveal errors as well? 为什么Android Studio UI也不会显示错误? Is gitbash
git push
different from commit and push in the android studio UI? gitbash
git push
不同于提交并推入android studio UI吗?
https://[serverip]:[gitlabport] isn't enough as a remote url: you are missing the name of a repo. https:// [serverip]:[gitlabport]作为远程URL是不够的:你缺少一个repo的名字。
This would be better: 这会更好:
git remote set-url origin https://[serverip]:[gitlabport]/<reponame>
<reponame>
should be the name of an empty repo declared through the GitLab web interface. <reponame>
应该是通过GitLab Web界面声明的空repo的名称。
So it isn't an issue of protocol (https vs. ssh: https will work just fine here). 所以它不是协议问题(https与ssh:https在这里工作得很好)。
It is an issue of url (which should include the name of a repo) 这是url的问题(应该包括repo的名称)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.