Thread (10 messages) flat view 10 messages, 5 authors, 2016-06-15

Re: Clone to an SSH destination

From: Konstantin Khomoutov <hidden>
Date: 2016-06-15 22:54:37

On Mon, 3 Sep 2012 11:21:43 +0100 (BST)
Mark Hills [off-list ref] wrote:
How do I clone a repo _to_ a new repo over SSH? I tried:

  cd xx
  git clone --bare . gitserver:/scm/xx.git
  git clone --bare . ssh://gitserver/scm/xx.git

This does not have the expected result, and instead a local path of
the given name is created (eg. a 'gitserver:' directory)
No, `git clone` is intended to work with your local machine.
And I can't really imagine how it would work in a way you want.
This seems to be a FAQ, but the only answer I can find (Google) is to 
login to the server and create the repo, setup a remote and push to
it. 
This is quite cumbersome; we have a large team of devs who use a
simple 'git clone' to an NFS directory, but we wish to retire NFS
access.

Is there a technical limiation preventing clone-to-ssh, or just
something waiting to be implemented?
I think this is more a conceptual issue: such a "remote cloning" would
mean *creation* of a repository as part of the process.  I'm not aware
of any [D]VCS system which would routinely allow such a thing: usually
the creation of a repository is an "administrative" act, which is
distinct from regular (push/fetch) access to that repository.

gitolite kind of implements this ("wild repos") [1], you could look if
it suits your needs.

Now back to your problem.

If you have NFS access, you can probably do proper cloning using NFS:
1) Export via NFS the directory in which you want your resulting
   bare repository located.
2) Do simple *local* clone (using paths accessed by NFS):
   git clone --bare /path/to/source/repo /path/to/destination/repo
3) Do certain fixups in the destination repo, if needed, then
   access it normally via SSH (or whatever protocol you prefer).

If you don't want to do this, then revert to a normal two-step
procedure:
1) Log into the server, create a repo by hand:
   git init --bare /path/to/repo
2) Push everything relevant from a source repo there:
   cd /path/to/local/repo
   git remote add origin ssh://gitserver/scm/xx.git
   git push origin refs/*:refs/*

Step (1) may depends on what server-side solution your need; for
instance, in gitolite you would be configuring a new repo in the
configuration file in your local clone of the gitolite admin repo and
pushing your changes to the server.

1. http://sitaramc.github.com/gitolite/wild.html
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help