Cygwin or msysgit Command-Line Usage on Windows

Last updated on
September 30, 2016 - 13:57

In a Windows environment, a shell environment lets you do things you might not otherwise be able to do, and lets you follow instructions just as if you were in a Mac or Linux environment.

There are at least two key ways to get a good command-line environment in Windows, and you should choose one of them. Cygwin is a fine environment that provides a rich set of tools. However, the MSysGit toolkit also comes with all the tools you need for basic Git usage and is an excellent, though more limited environment. (If you're using Tortoise Git you already have MSysGit.) Both will work fine for basic Git operations.

Using the shell will make it easier for you to follow handbook instructions, understand what is happening 'under-the-hood' and work under different operating systems.

Setting Up msysgit

To set up msysgit, simply download and install it, accepting the defaults at each point in the wizard. You'll end up with a start menu entry called "Git Bash", which is a command-line Bash shell which has a current version of Git and will work fine for any activity in the Git instructions. Everything should "just work".

For example, in a Git Bash window:

git clone --branch 6.x-1.x
cd examples
git log

Cygwin setup

Cygwin offers an enormous number of packages, but you can do most Drupal activities with just a few beyond the basic install.

If you already have Cygwin on your computer, but don't have all the packages you need, you will need to run the setup file again -- so follow along with these instructions.

  • Get the setup.exe file from
  • Run setup.exe and proceed through the screens.
  1. At the title screen just click 'Next'
  2. Choose 'Install from Internet'
  3. Root directory is usually best kept as default as are the other defaults
  4. Choose a location for downloading the installation files
  5. Select your Internet connection settings (probably the default 'Direct connection')
  6. Choose a download mirror
  7. Select packages either by section or by searching. Add at least openssh, git, rxvt, patch, patchutils, telnet, unzip, nano, vim, wget
  8. Click "Install"
  9. Cygwin is now installed on your system. If you want to add further packages later, you will need to run setup.exe again; so you may want to keep hold of the setup file. But you can always get the setup.exe again.

    Basic Cygwin Configuration

  10. Run "Rxvt Native" from the start menu. (On Windows Vista, Windows 7 or later, you need to right-click and run it as administrator this time because we'll be setting up links in a privileged directory). The first time you do this it will install default profile files for you.
  11. In rxvt we'll now set up symbolic links to the Windows filesystem. Do this for each drive you have... I'm showing the C: and D: drives here:
    cd /
    ln -s /cygdrive/c
    ln -s /cygdrive/d
  12. Now you can navigate into the Windows filesystem to wherever your Drupal install is. /c is the root of the C: drive; /d is the root of the D: drive. For example, if you have Acquia's DAMP installed, it might be in /c/Users/rfay/Documents/Sites/acquia-drupal or something like that.
  13. Simple Cygwin Usage

    Once you have Cygwin, you can do nearly anything you would do on the Linux command line.

  • Using git, I could check out the Examples project, for example:
    git clone --branch master
  • Or apply a patch using patch.... or using git apply or git am. All the normal patching instructions on project pages will "just work"

You have the easy-to-use editor nano if you want to edit within Cygwin, but you can just use the Windows editor of your choice as well.