How to Transfer Drupal 8 Files from WampServer with Git

Introduction: Using Git for Version Control with Drupal 8

This Tutorial will show how to transfer a Drupal 8 development website from a localhost environment running WampServer to a remote hosting platform using Git.

Git is used for version control in Agile development teams building new modules & themes for the Drupal 8 CMS. Git is free open source software for Linux & Windows.

Drupal 8 files can be pushed from the desktop programming environment to a sandbox, production server, or code repository depending on the requirements of the project.

Step One: Configure the Local Development Environment

To configure the local development environment to run Drupal 8, administrators need to have a localhost web server installed capable of running MySQL, PHP, & Apache.

The most popular localhost web server application for Drupal 8 is WampServer. Use of the Docker Desktop platform has become more common with container virtualization.

Other options for running a local development environment for Drupal 8 are Acquia Dev Desktop, Apache NetBeans (formerly Java), & VirtualBox with full web server stack.

Configure the local development environment with one of these options and install Drupal 8 locally. Then navigate to the Git website and download the latest Git package.

Download - Required Files:

Install the latest Git package on the desktop or laptop that is being used as a localhost web server for the Drupal 8 sandbox or development environment (Windows v.7-10).

How to Transfer Drupal 8 Files from WampServer with Git

After installation of the Git package, navigate to the Windows“Start” menu and type “git” into the Search bar. Double Click on the icon for “Git Bash” or make a shortcut.

How to Transfer Drupal 8 Files from WampServer with Git

In order to use Git to transfer files, confirm that the C:Program Filesgitbin folder has been created successfully with the installation. This folder is used as the Git cache.

How to Transfer Drupal 8 Files from WampServer with Git

Next: The Drupal 8 installation in the localhost environment needs to be connected to the remote web server or GitRepository using Git Bash commands for file transfer.

Step Two: Add Localhost Drupal 8 Path to Git Bash

Open the Git Bash command line utility & type the path to your localhost Drupal 8 installation. For those using WampServer according to the HostAdvice tutorial:

  • Localhost Drupal 8 Installation Path: C:wampwwwsite1

Confirm the path & enter the following command into Git Bash:

cd c:/wamp/www/site1

Next, use the CLI utility to check the status of the localhost Drupal 8 folder:

git status

The expected result to be returned is:

fatal: Not a git repository (oranyofthe parent directories): .git.

Enter the following command to initialize the folder as a Git Repository:

git init

The expected result to be returned is:

Initialized empty Git repository inc:/wamp/www/site1/.git/.

Now type:

git status

The result should be a list of all of the files excluded by .gitignore file settings:

How to Transfer Drupal 8 Files from WampServer with Git

Under the default Drupal 8 settings, none of the files are tracked by version control. In order to turn this on, use Git configuration & manual editing of the .gitignore files.

Step Three: Use Putty for SSH Connection to Web Server

To connect the localhost Drupal 8 installation with the remote web server, it is recommended to use PuTTY as the command line interface for Windows or similar.

Download - Required Files:

Install PuTTY for Windows on the desktop/laptop workstation environment. Collect the IP Address of the web server from the web host or configure it manually on the server.

How to Transfer Drupal 8 Files from WampServer with Git

Insert the IP Address & Port Number for your remote web server where the Drupal 8 files on the localhost will be transferred to. Open the SSH tab & confirm the defaults.

How to Transfer Drupal 8 Files from WampServer with Git

Note: In order to make a SSH Connection, create a Public Key in cPanel or with other software on your web server, then export the keys to PuTTY on the local workstation.

Step Four: Configure the Remote Web Server for Git

Connect to a cPanel web hosting account or other web server with a SSH Connection & test the environment by running the following commands:


This should return a list of files & folders in the root directory. Test the Git version:

git --version

Next, navigate to File Manager in cPanel & create a Git Repository in the root directory by creating a new folder or directory with the name:

  • mysite.git

Switch to the folder /mysite.git in PuTTY & run the command:

git init --bare

This creates a Git Repository on the remote server. Check for the folder /mysite.git/hooks and create a new file named “post-receive” in the folder.

Edit the “post-receive” file & add the following code:

GIT_WORK_TREE=/home/username/ git checkout -f

Change permissions on the file to 755. Save & exit to the desktop workstation.

Step Five: Add Remote Repository & Transfer Files

To finish, add the remote directory as a Git Repository with the following code:

git remote add mysite ssh://

Use the values created above on the remote web server & add them to the Git settings for the Drupal 8 files stored on the workstation. Then run the code:

gitpush mysite master

This will transfer all of the website files from the localhost development environment to the remote web server. Git can be further configured to track branches & versions.

In order to save time, it is recommended to use a remote staging environment & port Drupal 8 files via zip archives. Use the Backup & Migrate module to port the database.

Conclusion: Enable Advanced Version Control for Drupal 8

Git is a vital aspect of Version Control in Agile software development teams programming for the Drupal 8 ecosystem. It is the main basis of DevOps in practice.

Drupal 8 developers need to know CLI techniques, as well as Drush & Composer, to be most effective with managing websites & servers using Git for Version Control.

Check out these top 3 Drupal hosting services:

Was this article helpful?