How to Use Github and Submit a Patch

If you don’t know about git and github yet, it’s time you clean up your RSS feeds and find some good source of information.

Github is used by the Merb core team and I’ll show you how to use github to fork Merb, make your modifications and “submit your patch”.

This is the exact reason why github is simply awesome, it makes forking projects just super simple and submitting changes even easier.

First thing, you need to have a github account, if you don’t have one yet, email me, I have a couple of invitations left, otherwise, just wait until github gets public.

Now, let’s go to Merb’s repository and fork Merb-core by clicking on the fork button.

fork merb

Actually, for this example, I’ll fork merb-plugins because I want to improve the ActiveRecord rake tasks.

Because I forked merb-plugins, I now have my own forked repo: !my forked repo

I’ll start by checking out/cloning my forked repo locally.


git clone git<span class="iv">@github</span>.com<span class="sy">:mattetti</span>/merb-plugins.git

!git clone

Great I can now make my own changes…. but wait, what if the merb core team makes a change to the code? Well, I need to track their changes. Here is how:


git remote add coreteam git<span class="sy">:/</span>/

FYI, it adds the following to edit .git/config:


</tt>  [remote <span class="s"><span class="dl">"</span><span class="k">coreteam</span><span class="dl">"</span></span>]<tt>
</tt>  url = git<span class="sy">:/</span>/<tt>
</tt>  fetch = +refs/heads/*<span class="sy">:refs</span>/remotes/coreteam/*<tt>



git fetch coreteam

and finally


git checkout -b coreteam coreteam/master

You can now track the latest change and merge them with your branch. Note that you can also track other forks and merge some other changes. (just that feature is worth using git)

Alright, now you can do your stuff, and push your local change to your remote repo at github.

Once you are done, you can simply click on the “pull request button”

pull request button

fill up the form and select the recipient. (wycats in this example if you want him to merge your changes into the official version of Merb).

pull request

p.s: The github guys are working on a gem to make our loves easier, give a try. I’ll post about the gem when it will be a bit more stable.

By Matt Aimonetti