Skip to content
Advertisement

How can I determine the URL my git repo is located?

I am to work on a project and I have initialized a git repo on a server. Let’s suppose the URL of the server is

foo.bar

and the repo is at

/var/www/vhosts/foo.bar/httpdocs

I have created a git repo by running

git init

and then I created a .gitignore file, added whatever needed to be added, committed and from my local computer, which has ssh access to the server I have attempted to clone the repo, but I do not seem to find the correct URL or something is not set for the repo. I tried something like:

git clone https://foo.bar/httpdocs/.git

The error was

fatal: repository ‘https://foo.bar/httpdocs/.git‘ not found

I have tried with various pathes.

FYI: I have worked with git a lot in the past, but I have never set up a repository on a server, I have always received the path of repos created by someone else. Now I have created the repo, but I cannot seem to find out what the correct URL is. I have searched a lot to find this out, but unfortunately I did not find anything which would help me. Any ideas?

Advertisement

Answer

If you’re trying to communicate via SSH, you need the SSH link, not the HTTP(S) link:

git clone <user>@foo.bar:/var/www/vhost/foo.bar/httpdocs/.git

You need git and sshd (or openssh-server) installed on the remote server, and add your SSH key to the server, under the correct user (with ssh-copy-id, of course).

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement