Close and Go BackBack to Viget

Adding Gitjour to Your Hack Night Toolset

Patrick Reagan
Patrick Reagan, Development Director, March 26, 2009 1

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
David James said on 04/15 at 08:10 PM

Thanks for writing this up.  Just wanted to mention something from our hack session.  The wifi at Corner Bakery put us on the same subnet—and yet we were not able to see each other via Bonjour, probably because of some aggressive filtering by the Internet provider.  At that point I fetched my trusty ethernet cable from my backpack and we were in business.

Name:

Email:

URL:

Not an infant or robot? Please prove it:
How many days in a non-leap year?

Some HTML (strong, a, em) is allowed.

Notify me of follow-up comments?

We're the Developers

at Viget Labs. We write about web development trends, tips, best practices, industry events, and our projects — all with an emphasis on Ruby on Rails.

Contact Us

Have any questions, comments, ideas, or secrets to share? Let us know.


What is the third letter in apple?

Sorry, you need to have Javascript enabled to use this form. (Don't blame us, blame the spammers!) If you'd like to contact us, please visit our Contact page.