Search code examples
gitrepositorygit-remote

How to connect to a remote Git repository?


I am working with a team and we want to use Git (Not with GitHub, we have a private remote machine). We were using SVN until now. We have a remote machine that works like an SVN repository. Now, we want to turn this machine into the Git central repository. By what I have read, what everyone needs to do on their machines, is to install Git and use the following command to add the remote main repository:

git remote add origin <remote_repo_url>

But what is the remote_repo_url? How can I figure it out? Our remote machine has IP's like 189.14.666.666, in the remote machine I've installed Git and created a repository under C:\MY_GIT_REPOSITORY. What should I put in the URL on the local machines?


Solution

  • Now, if the repository is already existing on a remote machine, and you do not have anything locally, you do git clone instead.

    The URL format is simple, it is PROTOCOL:/[user@]remoteMachineAddress/path/to/repository.git

    For example, cloning a repository on a machine to which you have SSH access using the "dev" user, residing in /srv/repositories/awesomeproject.git and that machine has the ip 10.11.12.13 you do:

    git clone ssh://[email protected]/srv/repositories/awesomeproject.git