Skip to contentSkip to conversation

Why not clone to a remote directory over SSH

DISCUSSION Carl Baldwin 6 participants 13 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

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

Signature · 7 lines
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 Carl Baldwin                        Systems VLSI Laboratory
 Hewlett Packard Company
 MS 88                               work: 970 898-1523
 3404 E. Harmony Rd.                 work: [email protected]
 Fort Collins, CO 80525              home: [email protected]
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#1 lore raw
Quoted 2 lines · Carl Baldwin

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.

Signature · 2 lines
For a successful technology, reality must take precedence over public
relations, for nature cannot be fooled.
#2 lore raw
Quoted 7 lines · Nick Hengeveld
Quoted 2 lines · Carl Baldwin

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

Quoted 7 lines

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.

Signature · 3 lines
Andreas Ericsson                   [email protected]
OP5 AB                             www.op5.se
Tel: +46 8-230225                  Fax: +46 8-230231
#3 lore raw
Quoted 3 lines · Andreas Ericsson

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.

Signature · 2 lines
For a successful technology, reality must take precedence over public
relations, for nature cannot be fooled.
#4 lore raw

Hi,

Quoted 5 lines · Nick Hengeveld

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

#5 lore raw
Quoted 2 lines · Johannes Schindelin

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.

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

Signature · 2 lines
For a successful technology, reality must take precedence over public
relations, for nature cannot be fooled.
#6 lore raw

Hi,

Quoted 7 lines · Nick Hengeveld
Quoted 2 lines · Johannes Schindelin

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

#7 lore raw
Quoted 7 lines · Johannes Schindelin
Quoted 5 lines
Quoted 2 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.

Signature · 2 lines
For a successful technology, reality must take precedence over public
relations, for nature cannot be fooled.
#8 lore raw
In reply to Carl Baldwin
Quoted 4 lines · Carl Baldwin

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

#9 lore raw

Hi,

Quoted 1 line · Junio C Hamano
	$ 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

#10 lore raw
Quoted 3 lines · Johannes Schindelin

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.

Signature · 2 lines
For a successful technology, reality must take precedence over public
relations, for nature cannot be fooled.
#11 lore raw
Quoted 10 lines · Nick Hengeveld
Quoted 1 line · Johannes Schindelin

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.

Signature · 3 lines
Andreas Ericsson                   [email protected]
OP5 AB                             www.op5.se
Tel: +46 8-230225                  Fax: +46 8-230231
#12 lore raw
In reply to Johannes Schindelin
Quoted 8 lines · Johannes Schindelin
Quoted 1 line · Junio C Hamano
	$ 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