Last updated by ldaley
2 years ago
Most Grails-related source is hosted on GitHub, including the core source code, the functional test suite, and the source for the user guide. If you want to provide patches for any of these projects, then you should use git to generate them.This will allow you work against Subversion repositories (via Once you have git installed, you can fetch the source you want to work on from GitHub.The above command will create a new directory called "grails-core" and populate it with a clone of the project source. You won't be able to push changes back to the remote repository on GitHub, but that's not what we're trying to do.
This will create a local branch called "myChanges" and switch your working copy to it. You can now hack away to your heart's content!Once you have committed the changes that you want to your local branch, it's time to create the patch. First, make sure you're synchronised with the latest code:
Your local branch will now have the latest code from the master branch. For the next step, you have a couple of options. If you have created only one commit, then you can run:
This will generate a file in the current directory with the name "001-*.patch" that you can attach to a JIRA issue (you may have to create one first).On the other hand, if you have more than one commit you can generate patch files for them in one go. Simply execute
All commits in git are identified by a long hash like 8b0e042a7523558244ea1ac405e145c859ef0370. It look scary, but copy & paste is your friend! And that's how you generate a patch.
Getting hold of git
Before you can use git, you need to install it on your computer. This step is of course platform-dependent, but a few suggestions for some common operating systems follow.Windows
Download and run the msysgit installer. This will provide a shortcut from which you can start a command prompt dedicated to git. Once running, you execute git as you would for any other OS.Mac OS X
You have a couple of options. You can grab the dmg package or use MacPorts:sudo port install git-core +svn+bash_completion
git svn ) and give you bash completion.Linux
You can get RPM and Debian packages from the git download site, but it's usually easier to useapt-get or yum :sudo apt-get install git-core# orsu -c 'yum install git-core'
Cloning the repository
If you just want to create a patch for a project, then all you need is a read-only clone of the relevant project. You can find the URLs on the GitHub pages for each project. The HTTP URL is recommended since it works with HTTP proxies. So, let's take the Grails core project as an example:git clone http://github.com/grails/grails-core.git
Creating a patch
Before you start hacking away and making changes to the code, wait! It's often a good idea to work on local branches. So, once you've cloned the repository, run this from within the project directory:git checkout -b myChanges
git checkout master git pull git checkout myChanges git rebase master
git format-patch -1
git log and find the commit immediately preceding the first one you want to generate a patch for. You can then run:
git format-patch <commit ID>