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?
--verboseprints all connection attempts to stdout.--reuseaddrstops old connections from causing issues when restarting the server.--export-allmeansgit deamonwill allow pulling from repositories without agit-daemon-export-okfile.--strict-pathsisn’t so important for single-repo sharing, but avoids oversharing issues if you accidentally run the daemon from the wrong directory.--base-path=.gitremaps the path so guests don’t need to know where the repo is hosted on your machine, only the repo name..git/- this is the directory of the bare repo to whitelist/share. In other words, only share the git repository data, not your working directory.
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