Creating a Patch

So, you have moved on from just using Drupal and now you want to create a patch. For me, this started with making a patch for a contributed module and all I had to do was upload the patch to the issue.

The patch files are best created with git and this can be done on Linux or with Cygwin on Windows. The instructions are available at Patches | Drupal.org and are easy enough to follow, however it is also worth reading Advanced patch contributor guide | Drupal.org. My basic example is below:

Start by launching a Cygwin terminal session
cd /cygwin/c/sources/drupal

git clone --branch [base_branch] http://git.drupal.org/project/[module_name].git
cd [module_name]

# create a branch
git branch [module_id]-[fix_description]
git checkout [module_id]-[fix_description]

# make changes

# see which files changed
git status

# see exact changes
git diff

git commit
# if this complains run following two lines
# see your Drupal.org profile for this, under "Edit", "Git Access" git config --global user.email "[your_email]"
git config --global user.name "[your_name]"

# do actual commit with a message
git commit -a -m "[fix description]"

git diff [base_branch] > [module_name]-[fix_description]-[module_id]-[comment_no].patch