Git is great for distributed version control - you can share your commits with other developers without having to push to a remote origin. Very useful if you have multiple pieces of work going on in the same area of the codebase, for example. Running a git daemon is as straightforward as:
$ cd /Users/jim/git/repos
$ git daemon --export-all --base-path=.
At this point you should make sure remote login is enabled on your Mac. If you're not sure, go to Settings -> Sharing and ensure Remote Login is checked. Note the SSH command it tells you under "Remote Login: On".
Now from another machine on your network you should be able to add your Mac as a remote in git from within a repo:
$ cd /Users/charley/git/repos/teh-codez
$ git remote add jim git://[Jim's IP address]:9418/teh-codez
To check the remotes you have set up:
$ git remote -v
To pull any commits from the remote:
$ git pull jim master
If you get connection refused errors, ensure that you can SSH into the remote server and check that the git daemon is running on port 9418, the default.
Running the git daemon as a service
launchd configuration plist like so, saved under
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<string>Casper git daemon</string>
To check the configuration has worked it can be loaded using
launchctl (if you have git daemon launched from the terminal, kill it first):
The git daemon should now be up and running, and should always be started when you boot up your Mac.