Adding Gitjour to Your Hack Night Toolset

I have been interested in finding an effective way to use gitjour to share code with others during hack night gatherings, but I never really sat down to figure out the correct workflow. Until last night, that is.

At the Potomac Hackers meeting, David and I decided that we were going to collaborate on something that involved Sinatra, CouchDB, and the DataMapper CouchDB adapter. We didn't get to work on any of those things, but we did make some progress toward gitjour mastery. Here's what we did:

Setting Up A Repository

We discovered that it's best to have a separate, dedicated repository for serving through gitjour. Go ahead and create a separate directory that will house the main 'source' repository:

$ mkdir repositories $ cd repositories 

From here, you can either use an existing repository or start with a fresh one. To make things easy, let's create one from scratch:

$ mkdir scrappy $ cd scrappy $ git init $ touch README && git add . && git commit -m "Initial commit" 

You're almost ready to start sharing, but you'll need to decide if you want others to push changes back to you. If you do, add these lines to your local .git/config file:

[daemon] receivepack = true 

Since you won't be working out of the 'source' repository, now is a good time to make a local clone:

$ cd && git clone ~/repositories/scrappy 

Be mindful when enabling the daemon.receivepack option. This will allow anyone to push to your repository, so make sure you're on a trusted network. Read the documentation for git-daemon for more information.

Start Sharing

Return to your local repository directory and start using gitjour to announce your project:

$ cd ~/repositories $ gitjour serve scrappy Registered preagan-scrappy on port 9418. Starting service. 

Other users on the local subnet can now see your available repository:

$ gitjour list Gathering for up to 5 seconds... === preagan-scrappy on rogue.local.:9418 === gitjour (clone|pull) preagan-scrappy 

And clone it:

$ gitjour clone preagan-scrappy scrappy $ cd scrappy 

From this point on, collaborators can use the normal git commands to commit changes to their local repository and then push the changes back upstream with git push.

Cleaning Up

One of the side-effects of this process is that your original 'source' repository gets left in a dirty state. When you're ready to pack up for the evening, just reset the state of the repository and you're good to go:

$ git reset HEAD --hard 

Additional Tips

By default, gitjour will prefix your repository name with your current username or the value of gitjour.prefix. If you want to omit this prefix altogether, use a caret as part of the repository name:

$ gitjour serve scrappy ^scrappy 

If you have multiple repositories that you want to share, you can point gitjour at the containing directory:

$ gitjour serve ~/repositories 
Patrick Reagan

Patrick is development director in Viget's Boulder, CO, office. He writes clean Ruby code and automates system infrastructure for clients such as Shure and Volunteers of America.

More articles by Patrick