Submitting a drive-by commit to a GitHub project in under 5 minutes

I recently mentioned how I contributed C# syntax for CodeMirror; what I didn't talk about was how incredibly easy it was. I think the biggest obstacles to open source contribution are:

  • I'm not sure what I need to do, especially for this particular project / open source host
  • I don't have time to figure this out right now

What you might not know is that you can contribute useful code to a project in just a few minutes, even without having git installed or any git know-how - you could submit a patch from your mobile-device-of-choice if you really wanted to.

Note for the haters: The normal workflow to contributing to a project is via the standard git tooling, and I've done that. I was happily surprised to see that the github site supports project contribution without requiring that full workflow, which is nice for simple cases. The method I'm showing here is only appropriate for very simple changes.

1. Downloading the current source

If you're looking to contribute, you'll generally want the most current source. The simplest way to do that is to hit the download button, then grab the zip.

2011-06-17 15h00_35

2. Make and thoroughly test your changes

In my case, I made a change, verified I didn't break anything, and gave it the Works On My Machine official certification. At this point, I decided I wanted to contribute my change. Make sure to follow the standard practices here:

  • Make an isolated, useful change
  • Don't needlessly refactor existing code
  • Adapt to the coding style and architecture that are already in place

3. Fork the project on GitHub

If you're new to distributed version control systems (git, mercurial, etc.) the term "fork" may kind of throw you off. In the open source world, forking a project previously used to indicate that you were in some way unhappy with the original project and were starting up a new project. In DVCS, forking is good, natural, healthy, and beautiful. Try it: go fork a random project, check out your fork, and delete it. No harm done.

Forking a project on GitHub is literally a one-click thing:

2011-06-15 22h25_31

Word up. Now you have your own fork and can start making changes.

2011-06-17 12h17_00

4. Update your repo

Here's the trick I came across: if you're making a simple change, you don't need to do the git clone / push remote business. If you're planning to continue working on your fork long-term, of course, you'd want to do that, but if you're doing a drive-by contribution there's no need for any of that. You can browse to the file on your repo and edit it-place.

2011-06-17 15h45_40

So, click the edit button, copy your local edits in, enter a commit message, and commit your changes.

2011-06-17 15h52_14

5. Submit a pull request

Make sure you're happy with your changes, then submit a pull request. That's as easy as clicking the Pull Request link near the top of the page.

2011-06-17 15h55_19

Recap

If you already had a code change that you were happy with, you could easily follow the above steps in under 5 minutes. Don't torment project owners with low quality pull requests, but as someone who's admin'd several open source projects, I'm always thrilled to get a thoughtful submission. I'm generally more of a CodePlex / BitBucket fan, but you gotta hand it to GitHub - they've made the drive-by commit drop dead simple.

2 Comments

Comments have been disabled for this content.