George V. Reilly

Setting Up a Pairing Workstation for Chrome and Git

PairOn Chair

[Pre­vi­ous­ly published at the now defunct MetaBrite Dev Blog.]

At MetaBrite, we believe in the power of pair pro­gram­ming. We find that pairing helps for col­lab­o­ra­tion on difficult tasks, for exploring new areas, for knowledge transfer, and for spurring each other to better solutions. I find it to be fun, though it can also be exhausting. It’s not ideal for all our work—there’s no value in tying up two developers on some rote task that both know well.

Last week, I rebuilt our primary pairing work­sta­tion. In its previous in­car­na­tion, we had an account for each developer. Each of us had set up some personal pref­er­ences in our own user account, configured our editor(s), and hooked up our GitHub cre­den­tials. The arrange­ment worked but it was always dis­con­cert­ing to see a large number of Git checkins attributed only to "Fred" when you knew that both "Fred" and "Jim" had paired on that feature. We had adopted the convention of ending each commit message with "Pair: Fred & Jim", but that was easy to forget and hard to see.

Most of us have MacBooks as our work machines, but the pairing work­sta­tion is a beefy desktop system running Ubuntu 14.04. It has two monitors, two keyboards, and two mice. The monitors are mirrored so that each person can read the screen without neck or eye strain. The notion of a PairOn chair is amusing but I doubt that it would work well for us—we each have our own chair.

Chrome Profiles

When I rebuilt the machine, I set up only one user account, pair. I configured Chrome to have multiple profiles, one for each developer. This means that each of us can launch our own browser window where we can read our own email, access GitHub or Stack­Over­flow using our own identity, or log into our own copy of the LastPass password manager browser extension.

Git Pair

I also changed how we manage local commits to Git and how we push and pull from our GitHub repos­i­to­ries.

For local commits, we’re using some helper scripts from Pivotal. The git pair command updates user.name and user.email in .git/config based on values in .git/pairs:

For example, git pair fb sac updates .git/config thus:

user.name = Fred Beebe and Sheila A. Corn
user.email = pair+fred+sheila.a.corn@example.com

Based on .pairs in the project root:

# .pairs - configuration for 'git pair'
pairs:
  # <initials>: <Firstname> <Lastname>[; <email-id>]
  fb: Fred Beebe; fred
  jo: Jim Osward; josward
  sac: Sheila A. Corn; sheila.a.corn
email:
  prefix: pair
  domain: example.com
  no_solo_prefix: true
global: false

(Fred, Jim, and Sheila are a nod to the BBC Micro of my youth, not actual MetaBrite developers.)

Now git log shows a series of commits attributed to:

Author: Fred Beebe & Sheila A. Corn <pair+fred+sheila.a.corn@example.com>

These commits are created with git commit, as usual. You can use git pair-commit to attribute a commit to just one, randomly chosen member of the pair.

Multiple SSH Keys

I also wanted each of us to be able to push to or pull from the MetaBrite GitHub repos­i­to­ries, without having a shared SSH key.

I had each of us create an SSH key with passphrase, which we uploaded to our own GitHub accounts.

We then configured ~pair/.ssh/config with a series of Host entries, named after GitHub usernames:

Host            github-fredbeebe
    Hostname        github.com
    User            git
    IdentityFile    ~/.ssh/id_rsa_fredbeebe
    IdentitiesOnly yes
    PreferredAuthentications publickey

Host            github-josward
    Hostname        github.com
    User            git
    IdentityFile    ~/.ssh/id_rsa_josward
    IdentitiesOnly yes
    PreferredAuthentications publickey

# etc

And we set up a Git remote for each identity in each Git working copy:

$ cd ~/src/example
$ git remote -v
fred    git@github-fredbeebe:our_org/example.git (fetch)
fred    git@github-fredbeebe:our_org/example.git (push)
jim     git@github-josward:our_org/example.git (fetch)
jim     git@github-josward:our_org/example.git (push)

Here, our_org is the GitHub or­ga­ni­za­tion and example is the GitHub repository, which can also be found at https://github.com/our_org/example.

Adding a New Remote

To add a sheila remote, create an SSH key called id_r­sa_sheila­corn, upload the key to Sheila’s GitHub account, then add a github-sheilacorn Host entry to ~/.ssh/config:

Host            github-sheilacorn
    Hostname        github.com
    User            git
    IdentityFile    ~/.ssh/id_rsa_sheilacorn
    IdentitiesOnly yes
    PreferredAuthentications publickey

Finally, in each Git working copy:

$ cd ~/src/example
$ git remote add sheila git@github-sheilacorn:our_org/example.git

Now we can say:

All other Git commands behave just as before.

So far, it seems to be working well.

Tip

If you get "Too many au­then­ti­ca­tion failures for username" when using SSH, try using ssh -o 'I­den­ti­tiesOn­ly yes' instead. By default, ssh-agent will promis­cu­ous­ly offer many identities.

blog comments powered by Disqus
RunSnakeRun (wxPython) apps in a Brew Virtualenv » « On Blogging