3

I'm actually trying to push my work on my personal git server.

I just made a git init test, added and commited a test file, and added a remote pointing to server with git remote add. I didn't create a git repository on my server, so my ssh://git@XXX.XXX.XXX.XXX:XXXX/opt/git/test.git remote does not already exist.

I have the does not appear to be a git repository error.

The user "git" is the owner of the /opt/git directory.

Isn't that possible to create the non-existing repository by pushing to it for the first time? I could do it with ssh but this isn't very pratical... Isn't there an other way? I found no option for that.

I thank you for your help and I apologize for my possible spelling mistakes (I'm french).

Aniket Kulkarni
  • 12,825
  • 9
  • 67
  • 90
vmonteco
  • 14,136
  • 15
  • 55
  • 86

2 Answers2

4

No, there is no way for a push to happen automatically, if the remote specified is not a git repo itself.

You will have to ssh into your server, and run a git init to create an empty git repository.

It seems to me that you are trying to host your repository on your server, if that is the case, I would suggest using a bare repository. Basically, when initializing the repo, use git init --bare.

Also, I would suggest that you go through the various protocols for setting up git server, you are using the git protocol which requires additional steps as mentioned in the link, and that should save you some effort debugging the setup.

Community
  • 1
  • 1
Anshul Goyal
  • 73,278
  • 37
  • 149
  • 186
  • So I really have to access to my server with ssh. Thank you, I only wanted to know that, that answers my question. – vmonteco Jan 20 '14 at 11:48
  • You can also access the server using `git` protocol. On the remote side - create your repository `git init --bare test` and then run `git daemon` - this will start a listener on port 9418. Then you can run `git remote add foo git://server/` – First Zero Jan 20 '14 at 14:17
1

From what the error says, it seems that you should do a git init in the remote server directory before you push to it.

gravetii
  • 9,273
  • 9
  • 56
  • 75