It took me a while to figure out how to try to contribute to Rails now that it’s on Lighthouse / Github. Here’s what I do now, and it seems to work:
First, create a clone of the main git repository (not your fork of it – there’s really no reason to fork unless you want others to pull your changes before core accepts them):
Setup your development directories
mkdir rails cd rails mkdir patches git clone git://github.com/rails/rails.git source
Now you have:
rails |--patches `--source
Set up your dev branch
Then create a new branch where you’ll store just the changes you make for this patch:
git checkout -b your_patch_name master
Create the patch
Make your test-driven changes and when you are ready to create the patch run:
git diff -p master > ../patches/your_patch_name.patch
Setup a throwaway test branch
If you want to test your change
- create a new branch and apply the patch (this is useful if other commits have happened since you first created your patch)
- run the tests and make sure that everything passes
- clear your changes and delete the test branch
git checkout master git pull git checkout -b your_patch_name_test master git apply ../patches/your_patch_name.patch git stash ... git checkout master git stash clear git branch -D your_patch_name
Using git stash allows you to move back to the master branch without taking your changes with you – leaving you with a clean master branch. To learn more about git stash syntax, see the git documentation
Continue development
When it’s time to update the code you put in the patch, you can just rebase from the master branch:
git co your_patch_name git rebase master
Then you can fix whatever changes you need to fix and recreate your patch (or create a new one if your old changes were accepted).
Share you patch
The next step is to go to http://rails.lighthouseapp.com/ and create a ticket. Make sure that you
- tag it with “patch” as well as whatever else it applies to
- don’t forget to upload the patch itself.
When you upload, it appear in the middle of the right-hand column as a blue link – it’s hard to find, so look carefully. Then get as many people as possible to grab your changes and test them and add +1’s where necessary.
Summary
When all is said and done you are left with a directory full of patches you can apply, a clean master working copy and individual branches for all of your patches that you can maintain over time. While this was possible with subversion, it’s way cleaner with git. Contributing to rails is easier than ever!