9

I seem to often come across scenarios where I'd like to quickly give someone the means to clone a git repo from e.g. my laptop, and I'd like to perform this feat without running an SSH daemon, git daemon or any other kind of service requiring configuration (or even access control).

The simplest way I've come up with so far is to install the adsf command line web server gem for Ruby, make sure to run git update-server-info and then just run adsf in the directory I want to share. If I run it in the root of the repo, for example, I would then tell the other party to clone http://<my_hostname_or_ip>:3000/.git, or whatever port the server started on.

This works well enough, but does have the caveats of problems caused by concurrent access and the need to have Ruby and the particular gem installed.

What other tools or hacks do you use or know of that perform a similar function?

edit: to clarify, I'm looking for a solution like hg serve: ad hoc, quick and painless, requiring minimal setup and no persistent services.

Ilkka
  • 2,644
  • 1
  • 23
  • 27
  • Isn't just copying the repo as a directory enough for this scenario? – Šimon Tóth Apr 28 '11 at 10:26
  • @Let_Me_Be Copying the repo with what? It needs to go over the network after all. And that would only take care of the clone case, whereas the fetch case becomes necessary pretty quickly too. – Ilkka Apr 28 '11 at 10:29
  • What's wrong with just `git daemon`? – Noufal Ibrahim Apr 28 '11 at 10:30
  • @ilkka email, ftp, whatever :) When I need to quickly share a repo I just pack it and send it. – Šimon Tóth Apr 28 '11 at 10:30
  • Use a service like Dropbox or Ubuntu One and then share. If you have atleast one interest in your project, why not share via github or similar service? – daganh Apr 28 '11 at 10:34
  • @Noufal Ibrahim nothing that I know of. How does it solve this particular problem? Please elaborate in an answer :) – Ilkka Apr 28 '11 at 10:34
  • @daganh example scenario: super sikrit proprietary code (so github/dropbox/ubuntu one are out) in a company network (so anonymous is ok) related to one-off demo being developed by 2 people (so need to share does exist but not for long). – Ilkka Apr 28 '11 at 10:35
  • @Ilkka Dropbox is a completely encrypted solution that allows private sharing. Its a breeze to setup and will allow alot of freedom for you and your friend. If its that secret, then why not go through the trouble of ssh. – daganh Apr 28 '11 at 10:49
  • @daganh it's a matter of liabilities and policy as much as of technology. – Ilkka Apr 28 '11 at 11:26
  • daganh : As the recent dropbox fiascos show, the "cloud" is not all that trustworthy. If it's *your* data and *you* want to share it, using a 3rd party service should be a last resort. – Noufal Ibrahim Jun 24 '11 at 08:32

3 Answers3

14

Run this from somewhere.

git daemon --export-all --base-path=/tmp --port=9090 /tmp/foo/.git

/tmp/foo/.git is the directory you want to expose.

Then you can clone it somewhere else like so

git clone git://localhost:9090/foo testdir

And you'll get the repository in testdir.

Kill the server with ^C when you're done. It can also take options on what services to enable/disable. git help daemon for more info. I think it's much more straightforward than adsf.

Noufal Ibrahim
  • 71,383
  • 13
  • 135
  • 169
  • +1: if there is a network connexion between the two, and if the port isn't blocked by the company proxy, it is the right solution. – VonC Apr 28 '11 at 10:56
  • Thanks, this is what I was looking for :) Git daemon just stumped me at first, seemingly not being geared so much toward this scenario. – Ilkka Apr 28 '11 at 11:28
  • Well, that's why I asked you what was wrong with that. It seemed perfect for the job. :) – Noufal Ibrahim Apr 28 '11 at 11:33
  • 4
    I have `git config --global alias.serve 'daemon --reuseaddr --base-path=. --export-all --verbose'`. It makes daemon easy to use. – Josh Lee Apr 28 '11 at 20:55
7

For a clone shared between two user for a brief period of time, I would rather:

  • create only one file through git bundle
  • mail or copy that one file on the other developer workstation.

That would work even if there is no newtwork connexion between the two users.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
0

I'm usually running Apache, so it would be as simple as:

ln -s . ~/public_html/my_gift_repo
Amadan
  • 191,408
  • 23
  • 240
  • 301
  • This is fine and good, but I generally don't want to run HTTP servers on machines that aren't. – Ilkka Apr 28 '11 at 10:30