3

I have set up a simple server with a single git account to which I connect using SSH. I try to clone a repository located in its home directory (/srv/git) with git clone ssh://git@server:port/repository. It won’t work unless I prepend ~/ to the repository name. If I don’t prepend it, it will work only if the repository is located at the root of the filesystem.

Somehow, git is not realizing its own user directory. How can I change this “odd” behaviour so it works as expected? (at least for me)

1 Answers1

5

You have to provide an absolute path or a path using the ~ to indicate the home directory. Quoting from git-clone(1):

The ssh and git protocols additionally support ~username expansion:

  • ssh://[user@]host.xz[:port]/~[user]/path/to/repo.git/
  • git://host.xz[:port]/~[user]/path/to/repo.git/
  • [user@]host.xz:/~[user]/path/to/repo.git/

An alternate solution would be using something such as gitolite. Then you will be able to use repository URLs such as sshuser@host:reponame

Community
  • 1
  • 1
ThiefMaster
  • 310,957
  • 84
  • 592
  • 636
  • Exactly the enlightenment I was looking for. Thanks for que quick reply. –  Sep 07 '12 at 04:00
  • Could we all agree to let gitosis go now? (http://stackoverflow.com/questions/10888300/gitosis-vs-gitolite/10888358#10888358) – VonC Sep 07 '12 at 05:44