Quick and dirty git server

2 Nov '16

If you want to quickly share a Git repository with someone, you can use git daemon:

$ hostname
blah
$ cd my_repo/
$ git daemon \
    --verbose \
    --reuseaddr \
    --export-all \
    --strict-paths \
    --base-path=.git \
    .git/

Guests can now clone from you: git clone git://blah/my_repo. Note that this is completely unauthenticated read-only access!

If you’re lazy like me, you can create an alias so all you have to type is git serve (from the root of the repo):

[alias]
    serve = !git daemon --verbose --reuseaddr --export-all --strict-paths --base-path=.git .git/

So what do the options mean?

You might need to punch through your firewall. On Ubuntu, if you are using iptables, this is how you can check if you’ve already added a firewall rule and how to add a firewall exception. I believe this lasts until you restart:

$ sudo iptables -nL | grep 9418
$ sudo iptables -I INPUT 1 -p tcp --dport 9418 -j ACCEPT

git, Linux

Newer Older