0

I created a project and uploaded it on a centos 6 server. I installed git on server. Then I create a repository on somewhere in server (in directory public_html) with this command git init myproject.git --bare

Then i change permission of git directory with this command chown -R git:git myproject.git

In my local machine I want to clone project:

ssh://domain.com/myproject.git

but I get this error:

fatal: '/myproject.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.
farhad.a
  • 341
  • 4
  • 17
  • *Could not read from remote repository.* what did you set for remote origin repository? can you check the [remote origin](https://stackoverflow.com/questions/4089430/how-can-i-determine-the-url-that-a-local-git-repository-was-originally-cloned-fr)? – Bagus Tesa Apr 12 '19 at 01:01
  • I have been set this for remote origin repository: ssh://root@domain.com/myproject.git – farhad.a Apr 12 '19 at 01:02
  • ah my bad `ssh://domain.com/myproject.git` this seems, you need to check this url.. since you are using ssh, is your public key registered on the remote server? – Bagus Tesa Apr 12 '19 at 01:04
  • I added public key into this file: ~/.ssh/authorized_keys Is this correct? – farhad.a Apr 12 '19 at 01:05
  • err, `~/.ssh/authorized_keys` are you refering this on your local machine or the server for the `domain.com`..? adding public key to `authorized_keys` on a machine is telling them to trust the particular public key afaik. how do you usually authenticate to that `domain.com`? is it running bitbucket server or something else? – Bagus Tesa Apr 12 '19 at 01:14
  • Is your project really located at `/myproject.git` on the remote server? When using an SSH remote, the path is taken as absolute, not relative to the home directory. – bk2204 Apr 12 '19 at 01:14
  • I am referring ~/.ssh/authorized_keys on the remote server. because the remote server is linux. but my local machine is windows. – farhad.a Apr 12 '19 at 01:17
  • yes, myproject.git existed on remote server and it's located under public_html directory – farhad.a Apr 12 '19 at 01:17
  • 1
    Most sensible server setups refuse to let you ssh in as root, ever, for any reason. Try not using `root@` at all. Create a less-powerful user. Note that when using ssh access, the top level directory is the user's home directory, *not* the `public_html` directory. – torek Apr 12 '19 at 01:21

1 Answers1

0

The URL isn't correct for the location of your project. When you use ssh://example.com/myproject.git, that tells the server to look for the /myproject.git directory on the remote server. That is, the path is absolute, not relative, and you're telling Git that the project is in a directory at the root of the file system.

If you want to access a path under the public_html directory, you need to specify a different path. If you're logging in to access the user git's public_html directory, then you would need to specify something like ssh://git@example.com/home/git/public_html/myproject.git. If you're using a different user, specify a different username and home directory instead.

bk2204
  • 64,793
  • 6
  • 84
  • 100