Create Patch for Drupal

Obtain or update a copy of the project

1. Clone the project to obtain a copy of it that you can work with locally. You only need to do this once per project.

git clone --branch [branchname] http://git.drupal.org/project/[project_name].git

2. If you have already cloned, pull the latest changes down to ensure you're working on the latest code.

git checkout [branchname]
[branchname] might be 7.x-2.x for example. Refer : https://drupal.org/node/1054616

git pull

Creating patches via topic branch

3. Create and checkout a local "topic branch" for the issue you're working on.
(If the issue appears at http://drupal.org/node/123456 then the issue number is 123456.)

git checkout -b [issue-number]-[short-description]               # e.g. 123456-example-bug

4. Make whatever changes are necessary to see your issue fixed.

5. Confirm changes again:

git status

6. When you are satisfied, make one single commit with all your changes.
If you are NOT adding new files, you can do this using the -a option.
If you are adding new files, you'll need to git add the new files before making your commit.

git commit -a -m "Issue #123456 by username: Fixed all instances of foo bug." --author="username <username@domain>"
Make sure you add your drupal username and email

Commit message format should be Issue #[issue number] by [comma-separated usernames]: [Short summary of the change] --author="username <username@domain>"

7. When your code is ready to show people, grab the latest code once more.

git fetch origin

8. Make your code apply to the latest version of the code

git rebase origin/[branchname]              #e.g. [branchname] could be 7.x-2.x

9. Now, create your patch file.

git format-patch origin/[branchname] --stdout > [project_name]-[short-description]-[issue-number]-[comment-number]-[branchname].patch

10. Upload your patch to the Drupal.org issue attached to a new comment; remember to change the issue status to "needs review", to flag the issue for reviewers.

Done !! You have done your part to provide the patch.  Wish you tons of Drupal Credits !!

Add new comment