This year I authored several RubyGems and just this week finally learned how to work with a contributor.

UPDATE: @bryckbost points out that the github-gem does exactly what I wanted to do. See the Fetching and Evaluating Downstream Changes section of the README.

Of course GitHub has the great Merge pull request option when an auto-merge is possible, and I use that quite often, but the workflow on OSS projects sometimes requires you to run the tests locally and make any modifications before merging it.

A quick search didn’t turn up any easy to read instructions, and I’m no git guru, so it took me a few minutes to figure out a simple workflow.

Here is how I checked out, tested, modified, and merged a massive pull request for Ghee from Ryan Rauh this week.

1. Clone my repo and create a feature branch

git clone git@github.com:jonmagic/ghee.git
cd ghee
git checkout -b repos_support master

This creates a new branch called repos_support, based off of master, and checks it out.

2. Pull contributors code into your local branch

git pull https://github.com/rauhryan/ghee.git repos_support

This pulls the repos_support branch from the remote repo and merges it into the branch you have checked out (which we also called repos_support).

3. Run tests, make modifications, commit changes

bundle exec rake
touch OHNOES.txt
git add OHNOES.txt
git commit -m "Added OHNOES"

4. Checkout master, merge feature branch, push

git checkout master
git merge repos_support
git push

Conclusion

This workflow follows the kiss principle, so it worked quite well for me.

Please give me feedback. I would love to hear about how other people accomplish this task, so I encourage you to leave links/tips/tricks in the comments below.

Also be sure to checkout Ryan’s awesome work on Ghee, a simple ruby client for the GitHub API V3.