tags:

views:

137

answers:

3

Hi,

In 1 machine (ip 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 in the same WiFi network, How can I get clone from the other machine?

Thank you

A: 

ssh into that other machine and run git clone

xenoterracide
+3  A: 

You need to use a git+ssh url to perform the git clone:

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
Josiah
A: 

I assume that on both machines you have installed git.

Now what you do depends on what services you have installed, i.e. how you can connect from one machine to the other.

The simplest case is when you have sshd running on the machine you want to clone from, and you can ssh from the machine you want to clone to to the machine you want to clone from.

If you can do

ssh 192.168.1.2

(or if you have different username on the other machine, ssh [email protected]), then you should be able to clone via SSH, like Josiah wrote:

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

If you want to continue to fetch / push between machines, you should configure public key authentication for SSH, to not have to provide password on each fetch.


If you don't have sshd installed on source machine, you can clone using "smart" HTTP protocol if you have web server installed and can install CGI script (see git-http-backend manpage), or you can clone using "dumb" HTTP protocol if you have web server installed but can only serve static files (you would need to run git update-server-info in source repository first), or you can clone using rsync if you have it installed.

As a last resort you can use "git bundle" to create archive which you can move e.g. using USB pendrive and clone from it.

Jakub Narębski