Patching with Git
June 27th, 2008 by pyrat
Git is hard; but powerful. A wee bit of command porn for you for contributing with open source projects.
When sitting in a branch you have been working on for a new feature / bugfix which was created with the command:
git checkout -b cool_patch
To create a patch for the master branch which is a remote tracking branch for a read only git repo. Typically, this is an open source project which you cant push to therefore you need to patch.
git format-patch master --stdout > ~/patches/patchname.diff
Now you can create a ticket on the open source project with your patch.
-||-
To load a patch, its good to do it in a new branch.
So a workflow to applying a patch is as follows
git branch master git checkout -b new_patch cat ~/patches/patchname.diff | git am
You can then check you are happy and when you are. You can merge back into master by committing the branch changes then switching back to the master branch and merging your
git add . git commit -a -v git branch master git merge new_patch
Please correct me on any glaring errors you see. Im pretty much making it up as I go along.
June 28th, 2008 at 10:54 am
Can you get Tortoise SVN, the sub-version client for Linux? It’s easy-peasy and effective too.
July 29th, 2008 at 6:49 am
I think Tortoise in Windows only, I use the commandline for subversion tho, I find it easier. There must be seom svn guis for linux tho, any recommendations?