Contributing a patch to Drupal core
Mostly following http://drupal.org/node/1054616, the more advanced patch contributor guide.
First, move to whatever environment you set up test sites in.
To roll a patch for Drupal core, get the latest development copy of Drupal. The command for getting any new project from the repository is "git clone --branch [version] http://git.drupal.org/project/[name].git"
For Drupal core, you'll probably want to add an additional parameter to that command-- what to rename the directory to when you do the clone. You can use a word that refers to the issue, or if you don't feel like ever having to think about this, always use the issue ID.
git clone --branch 8.x http://git.drupal.org/project/drupal.git 1105954
git checkout -b 1105954-search-unpublished-nodes
It is definitely recommended to use the issue ID in the branch name for the branch you create to work on your patch in (done with the "git checkout -b" command).
Use Drush to rapidly install Drupal for testing purposes.
drush si --db-url=mysql://root:rootpass@localhost/1105954
The issue this patch is made for, "Search no longer returns unpublished nodes?," is a great example for a pure patching exercise, because Lech Piekarski (isilweo) - at the time a member of drupal.org for less than three months - identified the exact problem, right down to the line number, and Jennifer Hodgdon (jhodgdon) - one of the top contributors to Drupal 7 - instructed that the line should just be deleted.
I edited node.module (as with gvim modules/node/node.module) near the line identified by isilweo to remove the unwanted restriction to published nodes (" ->condition('n.status', 1)") and save the file. Then it's time to add the change to the repository index, commit it to the local repository, and make a patch file using the diff command:
git add modules/node
git commit -m "Remove condition preventing the return of unpublished nodes even to privileged users."
git diff origin/8.x > 100644-drupal-allow-search-unpublished-nodes-5-D8.patch
And upload the resulting patch file, 100644-drupal-allow-search-unpublished-nodes-5-D8.patch, to the issue and mark it needs review.
Creating a Patch with Git Diff
Take the hash of a 'before' commit and the 'after' commit 'sha' hash and stay relative to the current directory and output a patch:
~/code/dgd7/drupal/sites/all/modules/views$ git diff --relative 5ac40a1 cb64d08 > 817748-views-book-hierarchy-sort-12.patch