Upgrade Your Drupal Skills
We trained 1,000+ Drupal Developers over the last decade.
See Advanced Courses NAH, I know EnoughDrupal development using Git, Sublime Text and Console under Windows
This guide is compiled for Drupal Estonia Hackday where I held a workshop on Drupal development under Windows. For a long-time OSX user it struck me that creating a fully working development environment under Windows is not that hard at all.
Note that this guide only deals with command line and code editing experience, it does not help to set up LAMP stack for Drupal.
Getting started
- Install Console http://sourceforge.net/…est/download. Note that you will need to unpack, copy “Console2” dir to to “C:\Program Files (x86)” and create shortcut icon yourself.
What about Github for Windows?
Freshly baked http://windows.github.com eases some of the pain of setting up Git on Windows and also includes full Git command line client but it's best for developing for Github only. Non-Github remote repositories are supported, but they are a bit buggy, at least in initial version. At the time of writing only cloning works nicely, building local repo and assigning remote is not properly recognized and need extra steps. Also, re-using Github SSH keys requires command line knowledge and autogenerated dotfiles (.gitignore etc) might bring confusion for newcomers. Still this pretty Github application might bring a lot of potential in the future, especially for visual merging etc.
Setting command line alias for Sublime Text
- Run “Git Bash”
- Enter following commands:
echo 'alias sub="/c/Program\ Files/Sublime\ Text\ 2/sublime_text.exe"' >> ~/.profile source ~/.profile
Now you can enter sub .
in any directory in the command line to run Sublime Text.
Also, you might want to configure Sublime Text to more predictable startup experience. Go to Preferences → Settings – User and adjust following settings to false:
"hot_exit": false "remember_open_files": false
Setting Git default editor to Sublime Text
To save you from thrown into Vim when commiting without -m option it's wise to set Git to throw you to Sublime Text instead.
git config --global core.editor "'C:/Program Files/Sublime Text 2/sublime_text.exe'"
Set up Console to run Git shell
- Run Console
- Go to “Edit → Settings”
- Fill “Shell” field with
C:\Windows\SysWOW64\cmd.exe /c ""C:\Program Files (x86)\Git\bin\sh.exe" --login -i"
4. Fill “Startup dir” field with your working directory, usually something like C:\Users\your_username\your_working_directory
Set up Git config
git config --global user.name "my fullname goes here" git config --global user.email my_email_goes_here
Note that you must fill in my fullname goes here
and my_email_goes_here
. E-mail must match with e-mail you have used for registration in Drupal.org.
There are many additional tricks to set up a more workable Git config, for examples see here: http://coderwall.com/p/euwpig?…
Generate SSH Keys
ssh-keygen -t rsa -C "my_email_goes_here" sub ~/.ssh/id_rsa.pub
Note that you must to fill in my_email_goes_here
. Actually, it does not have to be e-mail, it can be any string but using e-mail is a convention.
Upload SSH keys
Then copy all the contents of the ~/.ssh/id_rsa.pub
file to:
…to Drupal.org:
…to Github:
Finally, lets started with Git
Creating new repo
mkdir test cd test git init echo "About this project" > README.txt git add . git commit -m "Initial commit"
Push repo to Drupal
First create a new sandbox project in http://drupal.org/…ject-project. When done, navigate to Version control tab and run
git remote add origin [email protected]:sandbox/your_drupalname/your_sandbox_id.git git push origin master
Note that you must to fill in your_drupalname
and your_sandbox_id
.
…or push repo to Github
Go to https://github.com/new, ignore “Initialize this repository with a README” setting.
git remote add origin [email protected]:your_username/your_projectname.git git push origin master
Note that you must to fill in your_username
and your_projectname
.
Git and Drupal development
Apply a patch with three lines
git clone http://git.drupal.org/project/drupal.git cd drupal curl link_to_the_patch | git apply
Note that you must to fill in link_to_the_patch
with actual URL
Roll back in one line:
git reset --hard
Create a patch for Drupal:
There is comprehensive manual for creating Drupal patches http://drupal.org/…instructions but in most simple form it goes like this:
git clone http://git.drupal.org/project/drupal.git cd drupal sub . ...edit something and save... git diff
This gives you a overview what you have changed. To save patch to a file, run:
git diff > ~/my_patches_dir/my_patch_name.patch
More info about Git
About Drupal Sun
Drupal Sun is an Evolving Web project. It allows you to:
- Do full-text search on all the articles in Drupal Planet (thanks to Apache Solr)
- Facet based on tags, author, or feed
- Flip through articles quickly (with j/k or arrow keys) to find what you're interested in
- View the entire article text inline, or in the context of the site where it was created
See the blog post at Evolving Web