Drupal git - art of patching

Here are all the commands, starting from creating a new copy of a drupal repository and up to creating the patch to be published in the issue queue, the examples are for drupal core but the same may apply to contrib modules and themes too.

Get the code
git clone --branch 8.x http://git.drupal.org/project/drupal.git

Change directory
cd drupal

Create a branch
git checkout -b branchnme
e.g.
git checkout -b 766458-seven-rtl-112

Add untracked (new) files
git add path/to/file
e.g.
git add themes/seven/ie7.css

Commit changes
git commit -a -m "commit message"
e.g.
git commit -a -m "issue 766458-seven-rtl add ie7.css"

Update origin
git fetch origin

Make your code apply to the latest version of the code
git rebase origin/8.x

Create patch
git diff origin/8.x > patchname.patch
e.g.
git diff origin/8.x > 766458-seven-rtl-112.patch
Or, if you want your patch to include author attributions (some credit for you) you should use:
git format-patch origin/[branchname] --stdout > [project_name]-[short-description]-[issue-number]-[comment-number].patch

Comments

By submitting this form, you accept the Mollom privacy policy.