GIT: How to checkout a module and create a patch

From Wowww mediawiki

Jump to: navigation, search

This page explains how to use GIT when creating a patch for a module.
If you already checked out the project, proceed with step 5.

  1. Checkout the latest version from a specified branch
    cd [dir where you want to checkout]
    git clone http://git.drupal.org/project/[modulename].git --branch [branchname]
    # e.g.: git clone http://git.drupal.org/project/ubercartgit.git --branch 6.x-2.x
  2. Check available branches
    git branch -a
  3. Check current branch
    git branch
  4. Update existing checkout
    git pull http://git.drupal.org/project/[projectname].git [branch]
    # eg:git pull http://git.drupal.org/project/ubercart.git 6.x-2.x
  5. After verifying you checked out the correct branch, make modifications to it and then make a diff.
    There are 2 ways creating a diff, depending if there are new files or only changed files.
    • Create a diff with only modifications to files
      git diff > [description]-[drupal.org issuenumber]-[drupal.org comment number].patch
      #eg: git diff > ubercart_review_order-1336226-3.patch
      OR:
    • Create a diff with new added files
      git add [path.to.new.file]
      git diff --staged > [description]-[drupal.org issuenumber]-[drupal.org comment number].patch


Attach this patch to a drupal.org issue comment

Personal tools