Getting started with Git (for Drupal) on Windows

New to Git? Take a look at Introduction to Git.

Install Git on your local machine

Download Git for Windows. Follow the link Download for Windows.

Install using default settings only.

Add Git Bash to the Taskbar. Open Start menu and type git. Right-click Git Bash then click Pin this program to the taskbar. In taskbar, right-click Git Bash icon, then right-click Git Bash, then click Properties.

  • Shortcut tab: Set the Start in option to your local server's root directory (e.g c:\xampp\htdocs)
  • Options tab: set Buffer Size to 500 or something large (Buffer size is number of lines for scrollbar to go back), check Quick Edit checkbox.
  • Click OK to close Properties dialog.

Configure git user. Open your Drupal.org account, click Edit, then Git access. Copy Git user configuration and paste it into Git Bash. Lines should look like this:

git config --global user.name "Your Name"
git config --global user.email you@example.com
git config --global core.autocrlf true

Hands-on: Hook up with an GIT repository

For git you need the "GIT backend" module.

Here is an example of using GIT backend:

Step 1: create an bare GIT repository (skip this if you already have one)

mkdir bare.git
cd bare.git
git init --bare

Step 2: set up your Drupal site with that repository

  1. Enable the "Version Control API", "Commit Log" and "GIT backend" modules.
  2. Flush cache.
  3. Go to Configuration > Development > Version Control settings (url: /admin/config/development/versioncontrol-settings)
  4. Set "Git binary path". (Notice: Can be problems with Windows OS. On *nix OS there are no problems with path)
  5. Go to Content > VCS repositories > Add Git repository in the admin area. (url: /admin/content/versioncontrol-repositories/add-git)
  6. Repository name: "Test repo", or whatever.
  7. Repository root: "/path/to/repository/bare.git".
  8. For other settings follow fields descriptions(and check "Web viewer URL handler" because by default it's not set. Might it'll be fixed in closest time)
  9. Save the repository.
  10. Enable the "Commit messages" menu entry, or go directly to the "/commitlog" path.

How to work on a patch that is not yet in core, but is needed as base cleanly

For twig we had the problem that the basic patch was not accepted, but that the followup issues should be clean.

The idea is to use two patches within one.

What do you do if you happen to find a patch with two patches in one?

Patch contributors

For patch contributors the workflow is not that difficult to the regular patches:

Assuming origin is the "core" repository and you work in feature branches the workflow is:

Lets further assume the patch is in issue 1806546 with comment number 4

Getting a clean branch:

# update core
git fetch origin
# checkout 8.x branch
git checkout origin/8.x
# checking out an issue feature branch with comment number
git checkout -b core-1806546-4

Applying the current patch:

wget .../patch.diff
# this directly _commits_ the patches, conflicts are resolved like
# with rebase / merge
git am patch.diff
# Now you fork again with your new comment number
git checkout -b core-1806546-5

Now you add your changes and then you do:

# this updates the original patch and can be done as often as you want
git commit --amend .
# this creates the new 2-part patch
git format-patch -M --stdout origin/8.x > mynewpatch.diff
# this creates the interdiff
git format-patch -M --stdout core-1806546-4 > interdiff.txt

Linkified Git log messages for drupalcode.org and Issue queues.

A small shell function which linkifies git log output.
Modified from Ben Almans github version

  • drupalcode.org commit link
  • drupalcode.org blob links
  • drupal.org issue link if the commit message is formatted as Issue #123456

Example of linkified git log

TortoiseGit Usage

This page explains how you can use TortoiseGit under Microsoft Windows to contribute code to Drupal.org.

Other pages in this handbook explain how to install and configure TortoiseGit, and the differences between git and tradional versioning systems like SVN.

Requirements:

  • You have requested and received git access.
  • You have created a project.
  • You have registered your public key with your drupal.org account.
  • You have installed and configured TortoiseGit.

Now:

1. Create an empty directory where the repository of your project should live. (If you already have files for your project, you can add them here later.)

2. Right click the repository directory you have just created and choose "Git Create repository here..." as shown below:
http://drupal.org/files/tortoisegit create repository

TortoiseGit should reply by saying that an empty repository has been created. The result is that you now have a directory that functions as a local git repository.

3. Create your project files in the repository directory or copy existing project files there.

4. Once you have at least one file in the repository directory, commit it. You do this as follows.

  • Right click the file(s).

Pages

Subscribe with RSS Subscribe to RSS - git