How to use GIT with Acquia Drupal hosting (aka Git For Dummies)
These are my private notes on Live Development on Acquia Drupal sites. They may be a little sparse and lacking a few details but they work. I made this due to a lack of details in Acquia's documentation. Consider it a git cheat sheet for dummies :)
How to do Live Development on Acquia Drupal
1. Enable live development
- Login to Acquia.
- On the Cloud > Workflow page, open the menu for your environment, and then click Enable Live Development.
- In the confirmation message, click Enable.
Note: Live Development can be enabled for Dev or Stage environments but not for the Prod environment.
2. How to connect via SSH
First, we'll use PuTTYgen to generate our public and private keys.
- Download PuTTYgen.
- Launch PuTTYgen, and then click the Generate button to generate your keys.
- Enter a unique key passphrase in the Key passphrase and Confirm passphrase fields.
- Save the both the public and private keys by clicking the Save public key and Save private key buttons.
- Click into the Public key for pasting into OpenSSH authorized_keys file field and copy all the text to your clipboard by pressing Ctrl-C.
Next, we'll add our public key to Acquia
- Click here to access your Acquia account's Credentials area.
- On the Credentials page, under SSH keys, click Add SSH key.
- Enter the SSH key nickname, which should indicate the owner of the key (aka you)
Paste the OpenSSH-formatted key into the SSH public key field. OpenSSH public keys start with
- Click Add key.
Now we'll add our private key to Filezilla (which is quicker and easier than futzing about with the command line for transferring files).
- Our key is in OpenSSH format and will need to be converted to PuTTY's PPK format. Launch PuTTYgen and from the "Conversions" menu, select the "Import key" option. Select the private key and follow the prompts to enter your pass phrase. Save your private key.
- If needed, download Filezilla and install it.
- Click on Edit > Settings and go to Connection > SFTP. Click the Add key file button to import your private key.
- Now you can launch Filezilla and connect to Acquia via SFTP.
You can use Filezilla for file transfers and Putty for committing files to git.
Login to Acquia with Putty
SSH command format: ssh sitename.environment@target_server.prod.hosting.acquia.com
SSH password: the 'nickname' for the public key (as set in Acquia)
- Open Putty
- Type in ssh email@example.com sitename: the name of the site, as set in Acquia environment: either dev or stage servername: Go to the User and keys page at Cloud > Users and keys to find both the sitename and servername.
- Hit enter
- Enter the password at the next prompt, then hit enter
- Boom - you should now be connected via SSH.
3. Move files
Use FileZilla to move files back & forth between your local environment and Acquia. SFTP access works *only* if Live Development is enabled. At that time, you will be able to find this directory:
For example, if your sitename is Sunrise and the environment is development, you would go to this directory (notice the lack of brackets):
4. Committing files
Once you're done editing files and uploading them, you need to commit them. If files are not committed ALL CHANGES WILL BE LOST. This is a must for working with Acquia. Committing files is done via SSH with Putty.
- Connect via PuTTY (or Terminal on Mac)
Navigate to the /livedev directory, like $ cd vol/ebs1/gfs/[sitename][env]/livedev
- The command $ cd /path/directory/name can be used to navigate to a specific directory
- $ cd .. can be used to move up into the containing directory (like from /sitename/path/directory to /sitename/path)
Use the following commands in sequence:
- $ git status - this will show you what files need to be committed
- $ git add . - this tells git that you want ALL uncommitted files to be committed
- $ git commit -m “Commit message (what changed?)” - this tells git you want to commit and adds a descriptive message so you know how this commit is different from others
- $ git push - pushes all changes to git - basically they are set in stone at a particular point in time
5. How to check if commit successful
Run the $ git status command again. If you followed the above instructions correctly, it should not list any changed files. If it lists changed files then you need to commit your changes properly (ie repeat the previous step).
6. Turn off Live Development
Once all changes are committed and $ git status shows no changed files, you can safely turn off Live Development without losing any change.
- Go to your Cloud > Workflow page in Acquia
- Open the menu for your environment
- Turn off Live Development
Once Live Development is off, you'll be able to drag your changed code from one environment to another.