Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I 'git clone' from another machine?

Tags:

git

git-clone

On one machine (IP address 192.168.1.2), I create a Git repository by

$ cd /home/hap/working $ git init $ (add some files) $ git add . $ git commit -m 'Initial commit' 

And I have another machine on the same Wi-Fi network. How can I get clone from the other machine?

like image 559
hap497 Avatar asked May 11 '10 05:05

hap497


People also ask

How do I clone a repository to another?

You first have to get the original Git repository on your machine. Then, go into the repository. Finally, use the --mirror flag to copy everything in your local Git repository into the new repo.

How do I clone to a local machine?

From your repository page on GitHub, click the green button labeled Clone or download, and in the “Clone with HTTPs” section, copy the URL for your repository. Next, on your local machine, open your bash shell and change your current working directory to the location where you would like to clone your repository.


1 Answers

You need to use a git+ssh URL to perform the Git cloning:

git clone git+ssh://[email protected]/~/working 

To break it down:

  • git+ssh tells Git that you want to use ssh to connect to the Git repository.
  • hap is your username (I assume based on the home directory in your question).
  • 192.168.1.2 is the machine that you want to connect to
  • ~/working is the path to your Git repository on the remote machine (so ~ is your home directory)

Some other things to note:

  • You need to have a ssh server enabled on the machine with the Git repository
  • You'll need to know the password for the user hap
like image 159
Josiah Avatar answered Sep 18 '22 16:09

Josiah