Last updated by mauk81 8 months 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.
Getting hold of gitBefore 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.
WindowsDownload 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 XYou have a couple of options. You can grab the dmg package or use MacPorts:
This will allow you work against Subversion repositories (via
sudo port install git-core +svn+bash_completion
git svn) and give you bash completion.
LinuxYou can get RPM and Debian packages from the git download site, but it's usually easier to use
Once you have git installed, you can fetch the source you want to work on from GitHub.
sudo apt-get install git-core# orsu -c 'yum install git-core'
Cloning the repositoryIf 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:
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.
git clone http://github.com/grails/grails-core.git
Creating a patchBefore 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:
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:
git checkout -b myChanges
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:
git checkout master git pull git checkout myChanges git rebase master
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
git format-patch -1
git logand find the commit immediately preceding the first one you want to generate a patch for. You can then run:
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.
git format-patch <commit ID>