# Why not clone to a remote directory over SSH

13 messages from 2005-11-23 to 2005-11-25. Participants: Carl Baldwin, Nick Hengeveld, Andreas Ericsson, Junio C Hamano, Johannes Schindelin, Linus Torvalds.
Thread: https://gitlist.dev/t/2663

## Carl Baldwin, 2005-11-23 21:16

Subject: Why not clone to a remote directory over SSH
Message-ID: <20051123211601.GA2260@hpsvcnb.fc.hp.com>
URL: https://gitlist.dev/e/20051123211601.GA2260%40hpsvcnb.fc.hp.com

```
It might be cool to enable cloning to a remote over ssh if the remote
doesn't yet exist.

% git clone . machine:/path/to/new/repository

If you try this now it will clone the current working repository to a
new directory called 'machine:'.

Carl

-- 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 Carl Baldwin                        Systems VLSI Laboratory
 Hewlett Packard Company
 MS 88                               work: 970 898-1523
 3404 E. Harmony Rd.                 work: Carl.N.Baldwin@hp.com
 Fort Collins, CO 80525              home: Carl@ecBaldwin.net
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

```

## Nick Hengeveld, 2005-11-23 23:08

Subject: Re: Why not clone to a remote directory over SSH
Message-ID: <20051123230838.GN3968@reactrix.com>
URL: https://gitlist.dev/e/20051123230838.GN3968%40reactrix.com
In-Reply-To: <20051123211601.GA2260@hpsvcnb.fc.hp.com>

```
On Wed, Nov 23, 2005 at 02:16:01PM -0700, Carl Baldwin wrote:

> It might be cool to enable cloning to a remote over ssh if the remote
> doesn't yet exist.

I would like to see the same for http.  There is limited support for
managing a repository using http but without the ability to run tools
like init-db/clone/update-server-info you still need shell access
or some other workaround.  I think it would be useful to allow someone
to create, manage, and share a repository without any special
intelligence on the server side.

-- 
For a successful technology, reality must take precedence over public
relations, for nature cannot be fooled.

```

## Andreas Ericsson, 2005-11-23 23:15

Subject: Re: Why not clone to a remote directory over SSH
Message-ID: <4384F7F6.10404@op5.se>
URL: https://gitlist.dev/e/4384F7F6.10404%40op5.se
In-Reply-To: <20051123230838.GN3968@reactrix.com>

```
Nick Hengeveld wrote:
> On Wed, Nov 23, 2005 at 02:16:01PM -0700, Carl Baldwin wrote:
> 
> 
>>It might be cool to enable cloning to a remote over ssh if the remote
>>doesn't yet exist.
> 
> 
> I would like to see the same for http.  There is limited support for
> managing a repository using http but without the ability to run tools
> like init-db/clone/update-server-info you still need shell access
> or some other workaround.  I think it would be useful to allow someone
> to create, manage, and share a repository without any special
> intelligence on the server side.
> 

You'll still need to install at least git-init-db and git-receive-pack 
(and git-merge, and...), even if they're run through commands from the 
web. That's pretty special intelligence.

You'd also have to add some logic to enter_repo() to make it find 
repositories without a HEAD correctly.

-- 
Andreas Ericsson                   andreas.ericsson@op5.se
OP5 AB                             www.op5.se
Tel: +46 8-230225                  Fax: +46 8-230231

```

## Junio C Hamano, 2005-11-23 23:26

Subject: Re: Why not clone to a remote directory over SSH
Message-ID: <7vd5kr3pz1.fsf@assigned-by-dhcp.cox.net>
URL: https://gitlist.dev/e/7vd5kr3pz1.fsf%40assigned-by-dhcp.cox.net
In-Reply-To: <20051123211601.GA2260@hpsvcnb.fc.hp.com>

```
Carl Baldwin <cnb@fc.hp.com> writes:

> It might be cool to enable cloning to a remote over ssh if the remote
> doesn't yet exist.
>
> % git clone . machine:/path/to/new/repository

I wonder if that is:

	$ ssh machine 'git clone '`hostname`:`pwd`' /path/to/new/repository'

Obviously you need a working git setup on the other end and
probably need to be much more careful shell-quoting if your
hostname and pwd has metacharacters, but...

```

## Nick Hengeveld, 2005-11-23 23:28

Subject: Re: Why not clone to a remote directory over SSH
Message-ID: <20051123232829.GO3968@reactrix.com>
URL: https://gitlist.dev/e/20051123232829.GO3968%40reactrix.com
In-Reply-To: <4384F7F6.10404@op5.se>

```
On Thu, Nov 24, 2005 at 12:15:02AM +0100, Andreas Ericsson wrote:

> You'll still need to install at least git-init-db and git-receive-pack 
> (and git-merge, and...), even if they're run through commands from the 
> web. That's pretty special intelligence.

If the server is DAV-enabled, a local git-init-db could use HTTP to
create an empty remote repository, and git-http-push can already send
local changes including merges etc. to such a remote repository.

Want to host your project using GIT?  Just use your .Mac iDisk.

-- 
For a successful technology, reality must take precedence over public
relations, for nature cannot be fooled.

```

## Johannes Schindelin, 2005-11-23 23:41

Subject: Re: Why not clone to a remote directory over SSH
Message-ID: <Pine.LNX.4.63.0511240038001.11106@wbgn013.biozentrum.uni-wuerzburg.de>
URL: https://gitlist.dev/e/Pine.LNX.4.63.0511240038001.11106%40wbgn013.biozentrum.uni-wuerzburg.de
In-Reply-To: <7vd5kr3pz1.fsf@assigned-by-dhcp.cox.net>

```
Hi,

On Wed, 23 Nov 2005, Junio C Hamano wrote:

> 	$ ssh machine 'git clone '`hostname`:`pwd`' /path/to/new/repository'

Obviously, this only works if the other side can connect to this side via 
ssh. Hmm. Firewalls? Disabled sshd? `hostname` not reliably returning a 
valid address for the remote side?

Hth,
Dscho

```

## Johannes Schindelin, 2005-11-23 23:45

Subject: Re: Why not clone to a remote directory over SSH
Message-ID: <Pine.LNX.4.63.0511240043300.11106@wbgn013.biozentrum.uni-wuerzburg.de>
URL: https://gitlist.dev/e/Pine.LNX.4.63.0511240043300.11106%40wbgn013.biozentrum.uni-wuerzburg.de
In-Reply-To: <20051123232829.GO3968@reactrix.com>

```
Hi,

On Wed, 23 Nov 2005, Nick Hengeveld wrote:

> If the server is DAV-enabled, a local git-init-db could use HTTP to
> create an empty remote repository, and git-http-push can already send
> local changes including merges etc. to such a remote repository.
> 
> Want to host your project using GIT?  Just use your .Mac iDisk.

That would be cool! And git-clone could be patched to do just that.

BTW, is it possible to convince git-http-push to store packs on the 
server?

For that matter, is it possible to generate the file(s) needed for a dumb 
server on the client side?

Ciao,
Dscho

```

## Nick Hengeveld, 2005-11-24 00:19

Subject: Re: Why not clone to a remote directory over SSH
Message-ID: <20051124001955.GP3968@reactrix.com>
URL: https://gitlist.dev/e/20051124001955.GP3968%40reactrix.com
In-Reply-To: <Pine.LNX.4.63.0511240038001.11106@wbgn013.biozentrum.uni-wuerzburg.de>

```
On Thu, Nov 24, 2005 at 12:41:56AM +0100, Johannes Schindelin wrote:

> Obviously, this only works if the other side can connect to this side via 
> ssh. Hmm. Firewalls? Disabled sshd? `hostname` not reliably returning a 
> valid address for the remote side?

If sshd is running locally, you can forward a port back to yourself and
have the remote clone localhost:`pwd`.  Assuming there's a way to clone
using a nonstandard port.

-- 
For a successful technology, reality must take precedence over public
relations, for nature cannot be fooled.

```

## Linus Torvalds, 2005-11-24 00:51

Subject: Re: Why not clone to a remote directory over SSH
Message-ID: <Pine.LNX.4.64.0511231645100.13959@g5.osdl.org>
URL: https://gitlist.dev/e/Pine.LNX.4.64.0511231645100.13959%40g5.osdl.org
In-Reply-To: <Pine.LNX.4.63.0511240038001.11106@wbgn013.biozentrum.uni-wuerzburg.de>

```


On Thu, 24 Nov 2005, Johannes Schindelin wrote:
> 
> On Wed, 23 Nov 2005, Junio C Hamano wrote:
> 
> > 	$ ssh machine 'git clone '`hostname`:`pwd`' /path/to/new/repository'
> 
> Obviously, this only works if the other side can connect to this side via 
> ssh. Hmm. Firewalls? Disabled sshd? `hostname` not reliably returning a 
> valid address for the remote side?

Well, you could also just script it and just do

	ssh machine 'mkdir -p /path/to/new/repository ;
		cd /path/to/new/repo;
		git-init-db'
	git push --all machine:/path/to/new/repository
	ssh machine 'cd /path/to/new/repo ; git checkout'

(and yes, we could obviously make this a "git-create-repo" command, and 
then you could do

	git-send-pack --exec=git-create-repo \
		machine:/path/to/new/repository
		$(git-rev-parse --all)

or something like that).

		Linus

```

## Nick Hengeveld, 2005-11-24 01:04

Subject: Re: Why not clone to a remote directory over SSH
Message-ID: <20051124010409.GQ3968@reactrix.com>
URL: https://gitlist.dev/e/20051124010409.GQ3968%40reactrix.com
In-Reply-To: <Pine.LNX.4.63.0511240043300.11106@wbgn013.biozentrum.uni-wuerzburg.de>

```
On Thu, Nov 24, 2005 at 12:45:18AM +0100, Johannes Schindelin wrote:

> BTW, is it possible to convince git-http-push to store packs on the 
> server?

Certainly, I'm not sure what conditions make sense for using packs
though.

When pushing changes to the server, there's an advantage to using loose
objects in that there is no way to resume a failed transfer.  So if the
network barfs 99% of the way through, you'll be much less annoyed if
you need to retransmit the one object rather than a whole pack.

The same problem exists if you decide to pack loose objects on the
server since the pack would have to be generated locally and then sent
to the server.  At least in this case, other remote clients would still
be able to fetch loose objects while packs were in transit.

> For that matter, is it possible to generate the file(s) needed for a dumb
> server on the client side?

Which files are those?  I've been working on a way to update info/refs
and eventually objects/info/packs.

-- 
For a successful technology, reality must take precedence over public
relations, for nature cannot be fooled.

```

## Andreas Ericsson, 2005-11-24 08:14

Subject: Re: Why not clone to a remote directory over SSH
Message-ID: <43857649.2080502@op5.se>
URL: https://gitlist.dev/e/43857649.2080502%40op5.se
In-Reply-To: <20051124001955.GP3968@reactrix.com>

```
Nick Hengeveld wrote:
> On Thu, Nov 24, 2005 at 12:41:56AM +0100, Johannes Schindelin wrote:
> 
> 
>>Obviously, this only works if the other side can connect to this side via 
>>ssh. Hmm. Firewalls? Disabled sshd? `hostname` not reliably returning a 
>>valid address for the remote side?
> 
> 
> If sshd is running locally, you can forward a port back to yourself and
> have the remote clone localhost:`pwd`.  Assuming there's a way to clone
> using a nonstandard port.
> 

ssh://host.xz:port/path/to/repo.git

should work. If it doesn't I'll fix it.

-- 
Andreas Ericsson                   andreas.ericsson@op5.se
OP5 AB                             www.op5.se
Tel: +46 8-230225                  Fax: +46 8-230231

```

## Johannes Schindelin, 2005-11-24 10:36

Subject: Re: Why not clone to a remote directory over SSH
Message-ID: <Pine.LNX.4.63.0511241136370.12985@wbgn013.biozentrum.uni-wuerzburg.de>
URL: https://gitlist.dev/e/Pine.LNX.4.63.0511241136370.12985%40wbgn013.biozentrum.uni-wuerzburg.de
In-Reply-To: <20051124010409.GQ3968@reactrix.com>

```
Hi,

On Wed, 23 Nov 2005, Nick Hengeveld wrote:

> On Thu, Nov 24, 2005 at 12:45:18AM +0100, Johannes Schindelin wrote:
> 
> > For that matter, is it possible to generate the file(s) needed for a dumb
> > server on the client side?
> 
> Which files are those?  I've been working on a way to update info/refs
> and eventually objects/info/packs.

These I meant.

Ciao,
Dscho

```

## Nick Hengeveld, 2005-11-25 20:26

Subject: Re: Why not clone to a remote directory over SSH
Message-ID: <20051125202640.GS3968@reactrix.com>
URL: https://gitlist.dev/e/20051125202640.GS3968%40reactrix.com
In-Reply-To: <Pine.LNX.4.63.0511241136370.12985@wbgn013.biozentrum.uni-wuerzburg.de>

```
On Thu, Nov 24, 2005 at 11:36:58AM +0100, Johannes Schindelin wrote:

> > > For that matter, is it possible to generate the file(s) needed for a dumb
> > > server on the client side?
> > 
> > Which files are those?  I've been working on a way to update info/refs
> > and eventually objects/info/packs.
> 
> These I meant.

Yes - it should be straightforward to generate those files on the client
side.  A PROPFIND request for the remote directory with Depth: 1 will
return a list of files in the directory, so refs and objects/packs can
be crawled to generate the contents of the server info files.  That's
assuming that packs and tags are being pushed of course.

Come to think of it, PROPFIND is probably a more efficient way to check
for the existence of an object in the remote repo as well.  That would
make it feasible to remove the --complete option and always verify the
full history.

-- 
For a successful technology, reality must take precedence over public
relations, for nature cannot be fooled.

```
