4

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?

Community
  • 1
  • 1
crusam
  • 6,140
  • 6
  • 40
  • 68
  • 1
    What does `git remote -v` tell you? You should have `origin` set to whatever URL you specified. Further, what does `git push -u origin master` tell you? Do you successfully push content? – Makoto Mar 14 '15 at 22:28
  • git remote -v shows "origin http://serverip:gitlabport (fetch) and another row with the same and (push). But git push -u origin master seems to reveal the error. It complains about my ssl certificate which I signed by myself. "fatal: unable to access 'https://serverip:gitlabport/' SSL certificate problem: self signed certificate. That already helps, guess I should get used more to the gitbash console, instead of trying to fix everything in the android studio UI, since there no error was shown. Do you know how to let git accept self signed certificates? – crusam Mar 14 '15 at 22:56
  • and thank you for pointing me to the right direction! – crusam Mar 14 '15 at 22:56
  • You should clarify what the *actual* problem is in your question. Include the error message you're seeing and be sure that the question title matches with the trouble you're encountering. If it were any other Git setup, I would've thought you hadn't pushed anything yet because you weren't sure *how* to push. – Makoto Mar 14 '15 at 22:57
  • I rephrased the question and was able to manage the ssl certificate problem. And you are still right. I am not too familar with the differences between commit and push. I didn't expect git to be that much different from svn. I wanted to setup the enviroment and then use the learning by doing approach, but guess I will have to get more into basics first before beeing able to completly setup the enviroment. – crusam Mar 14 '15 at 23:48

1 Answers1

7

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)

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • just created a repository in the gitlab webinterface, and it worked as you discribed, thank you! – crusam Mar 15 '15 at 00:16