Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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. 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. The installation was done fast and I was able to connect to the webinterface on the server from my local machine.

Now I wanted to push a prototype in form of an android project to my GitLab Repository on the server. 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?).

Ok, next I of course want these committed files to end up in a Repository of my GitLab remote server. 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

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.

Using gitbash to push as suggested by Makoto with

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? And why does the Android Studio UI not reveal errors as well? Is gitbash git push different from commit and push in the android studio UI?

like image 858
crusam Avatar asked Mar 17 '23 18:03

crusam


1 Answers

https://[serverip]:[gitlabport] isn't enough as a remote url: you are missing the name of a 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.

So it isn't an issue of protocol (https vs. ssh: https will work just fine here).
It is an issue of url (which should include the name of a repo)

like image 141
VonC Avatar answered Mar 19 '23 07:03

VonC