threads / discuss / 2663

Why not clone to a remote directory over SSH

Subject: Why not clone to a remote directory over SSH

## tl;dr

13 messages between Nov 23, 2005 and Nov 25, 2005.

replies: 12people: 6as markdown or json

Carl Baldwin· Nov 23, 2005, 21:16 UTC · lore

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· Nov 23, 2005, 23:08 UTC · re: Carl Baldwin · lore

Re: Why not clone to a remote directory over SSH

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· Nov 23, 2005, 23:15 UTC · re: Nick Hengeveld · lore

Re: Why not clone to a remote directory over SSH

Nick Hengeveld wrote:
Show 14 quoted lines
> 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
Nick Hengeveld· Nov 23, 2005, 23:28 UTC · re: Andreas Ericsson · lore

Re: Why not clone to a remote directory over SSH

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· Nov 23, 2005, 23:45 UTC · re: Nick Hengeveld · lore

Re: Why not clone to a remote directory over SSH

Hi,
On Wed, 23 Nov 2005, Nick Hengeveld wrote:
Show 5 quoted lines
> 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· Nov 24, 2005, 01:04 UTC · re: Johannes Schindelin · lore

Re: Why not clone to a remote directory over SSH

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.
Johannes Schindelin· Nov 24, 2005, 10:36 UTC · re: Nick Hengeveld · lore

Re: Why not clone to a remote directory over SSH

Hi,
On Wed, 23 Nov 2005, Nick Hengeveld wrote:
Show 7 quoted lines
> 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· Nov 25, 2005, 20:26 UTC · re: Johannes Schindelin · lore

Re: Why not clone to a remote directory over SSH

On Thu, Nov 24, 2005 at 11:36:58AM +0100, Johannes Schindelin wrote:
Show 7 quoted lines
> > > 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.
Junio C Hamano· Nov 23, 2005, 23:26 UTC · re: Carl Baldwin · lore

Re: Why not clone to a remote directory over SSH

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...

Johannes Schindelin· Nov 23, 2005, 23:41 UTC · re: Junio C Hamano · lore

Re: Why not clone to a remote directory over SSH

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

Nick Hengeveld· Nov 24, 2005, 00:19 UTC · re: Johannes Schindelin · lore

Re: Why not clone to a remote directory over SSH

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.
Andreas Ericsson· Nov 24, 2005, 08:14 UTC · re: Nick Hengeveld · lore

Re: Why not clone to a remote directory over SSH

Nick Hengeveld wrote:
Show 12 quoted lines
> 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
Linus Torvalds· Nov 24, 2005, 00:51 UTC · re: Johannes Schindelin · lore

Re: Why not clone to a remote directory over SSH

On Thu, 24 Nov 2005, Johannes Schindelin wrote:
Show 8 quoted lines
> 
> 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

← back to recent threads