Drupal Association members fund grants that make connections all over the world.
Last updated August 27, 2015.
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 C:\Program Files\Git\bin to the system path. Modifying the path differs across Windows versions. (If you do not do this, you will not be able to use drush or invoke git from a command shell.)
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 email@example.com git config --global core.autocrlf true git config --global core.safecrlf true
Before you begin, you can optionally run a few Git configuration commands to make Git more legible. You only need to do this once, and the options will be saved in your .gitconfig file. Open Git Bash and type the following commands:
git config --global color.status auto git config --global color.branch auto git config --global color.interactive auto git config --global color.diff auto
Need more information about Git configuration? Take a look at Configuring Git.
Create a new git repository
You can start by downloading new Drupal project or using existing one.
Open Git Bash and navigate to your Drupal site folder using the change directory (cd) command:
[Replace [UserName] with your user name]
Note: Git Bash will change directory path structure too look more "Unix-like".
c:\xampp\htdocs in Windows command shell will become
c/xampp/htdocs in Git Bash
Check if you already have git repository initialized in the folder by typing
git status. You should receive error message
fatal: Not a git repository (or any of the parent directories): .git.
git init to initiate empty repository. You should receive following message:
Initialized empty Git repository in c:/xampp/htdocs/my-fancy-drupal-project/.git/.
Make an initial commit
git status to check the status of your new repository. Result should look like this:
# On branch master # # Initial commit # # Untracked files: # (use "git add <file>..." to include in what will be committed) # # .gitignore # .htaccess # CHANGELOG.txt # COPYRIGHT.txt ... # update.php # web.config # xmlrpc.php nothing added to commit but untracked files present (use "git add" to track)
So all of your files are in Git repository folder but are still not tracked by Git.
Add all files to Git’s staging area:
git add -A or
git add .
Commit all the changes in the staging area to the repository with a message:
git commit -m "Initial Drupal commit"
git status to check the status.
# On branch master nothing to commit, working directory clean
That's it! Your files were successfully committed to your local Git repository.
Need more info? Look at Recording Changes to the Repository chapter of official Git Book.
Connecting to the remote server via PuTTY
Download and run PuTTY SSH client (putty.exe) to setup git on your remote server. Type in the server you want to access in Host Name: e.g., your_username@your_domain_name.com, then click Open. An SSH session will launch and you will be prompted for a password (this will be specific to SSH and probably needs to be set up through your host’s control panel).
In your SSH session on PuTTY:
$ git help git
This opens the git help documentation; press q to exit the documentation. This will ensure git is working on your remote server.
Connect to the server via SSH and enter the following commands:
tar zxvf drush-7.x-5.0.tar.gz
ln -s ~/drush/drush ~/bin/drush
Importing to Acquia Dev Desktop
Open GIT Bash
Navigate to the Sites directory: $ cd Sites
Create a new directory for your site: $ mkdir SiteName
Navigate to the directory you created: $ cd SiteName
Use a Git clone command to download the site setup: $ git clone https://github.com/your_user_name/your_repository_name.git
You may want to move directories around: $ mv ~/Sites/SiteName/RepositoryName/* ~/Sites/SiteName
Make sure that .git, .gitignore and .htaccess transferred.
Use the Backup and Migrate module to migrate and save of copy of your site database to a directory on your local computer.
Start Acquia Dev Desktop Control Panel
Select the dropdown menu below Go To Site and select more.
In the new window, under Site Path, navigate to the Sites/SiteName directory.
Under Database, select Create a New Database and name the database SiteName.
Change the name under Server to SiteName.
Note: You may get an error message, “Error:hosts file doesn't exist or is not writable. 'C:\Users\Administrator\Windows\system32\drivers\etc\hosts'. If that is the case, find the C:\windows\system32\drivers\etc\hosts file; right click; select Properties; un-check Read only; create your new site in the Acquia Dev Desktop Control Panel. Once you are successful in creating the site, go back to the hosts file properties and check Read Only. If this doesn’t fix the error, try disabling your anti-virus software temporarily.
Now run install.php by going to sitename:8082/install.php
Create new users for your site, preferably with the same details as your main admin accounts.
Log in as an Administrator, go to Modules, and enable the Backup and Migrate Module
Go to Configuration > Backup and Migrate > Restore, then navigate to the .mysql.gz file that Backup and Migrate created from your remote site earlier.
You may want to upload some files like Site Logo and favicon.ico on the Appearance > CurrentSiteTheme > Settings page.
Getting Drush working in GIT BASH
Install Drush for Windows. When installing, be sure to select the option “Register environmental variables”.
Copy the following path: C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;C:\ProgramData\Drush\;C:\Program Files (x86)\Drush\GnuWin32\bin;C:\Program Files (x86)\Drush\Php
In Windows, select Start>Computer>Properties>Advanced system settings>Environment Variables>New. For Variable name, type “C:\path” and for Variable value paste the path you've just copied.
Open git bash.
Test Drush is working: $ drush status
If getting Changes not committed
This could be caused by file deletions. Try: $ git add -u