0

I've setted up a remote repository with git, connecting with ssh.

  1. Create project - remote side.
    When I create a project directly from server, then I easily clone (and push/pull operation) it client side.

  2. Create project - client side.
    Doing:

    cd testProj
    git init
    git add remote git@:testProj
    git add . && git commit -m "First" && git push origin master

I get error:

fatal: '/home/git/testProj.git' does not appear to be a git repository fatal: Could not read from remote repository.

Please make sure you have the correct access rights and the repository exists.

How can I grant write-access to some user?

I've already pasted $(cat ~/.ssh/id_rsa.pub) on .ssh/authorized_keys server side.

SirDeveloper
  • 276
  • 1
  • 10

2 Answers2

0

Git over SSH uses the remote servers own authentication/authorization scheme. Does the pushing user have read/write access to the entire testProj directory and all subdirectories? Moreover; GIT requires a remote repository to be present where you are pointing your remote. In other words, you can't push to a remote server if there is not already a repository present. You need to cd into the directory where you want your remote first, and execute git init --bare

Martin Nielsen
  • 1,865
  • 6
  • 30
  • 54
  • Hi martin, thanks for answer. Well, let me call R=remote server and B=a generic user. Now, B can login via ssh without inserting psw because I pasted its public key on R. If proj already exist in R, I can work with it, if not exist and I B would create and push it, can't! – SirDeveloper Feb 04 '16 at 12:03
  • So are you saying that the project does not exist on the remote at all? – Martin Nielsen Feb 04 '16 at 12:04
  • I've updated my answer. It is not so much a solution though. Git simply does not allow you to push a repository to the remote server if you have not initiated a repository there first. Basically, you have to go to the directory and execute 'git init --bare' first. – Martin Nielsen Feb 04 '16 at 12:14
0

You need to first log in the server and create the empty repository.

A one liner is

ssh git@... git init --bare testProj

If you you're using git-shell you might need to read this other question.

Community
  • 1
  • 1
Jonas Malaco
  • 1,557
  • 9
  • 18