Starting With Git

Use Git version control to deploy code to your Drupal or WordPress site's development environment.


Git is the version control tool at the heart of the Pantheon workflow. If you're a developer who likes to use local development, it's a good way to work with the Pantheon platform: develop locally, commit, and push to master to deploy code into your Pantheon Development environment.

Web Team Agility Assessment

How mature is your web team? Take our Web Team Agility Assessment to find out.

Install Git

Select your operating system and the download will automatically begin:

Clone Your Site Codebase

The first step is to get a git clone of your code from Pantheon to your local computer.

Step 1: Go to Your Site Dashboard

Log in to Pantheon and load the Dashboard for the site you want to work on.

Step 2: Copy the Git Clone Command

At the top of the development panel, look for the git clone command and copy and paste it in your terminal. It will look something like this:

Copy Past Git Clone

Step 3: Run Git Clone

On your local environment, go to where you want the code to reside. Git will create a directory as part of the clone, so you don't need to create one. Run the command you copied in step 2:

git clone ssh:// my-site

If everything worked correctly you will see Git fetching the data:

Git Clone During

If you run into permission problems, check your SSH key setup. If the clone starts but can't complete, check your network to see if you have a current version of Git.

Make a Change

Step 1: Edit a File

You can now edit your site code using any text editor. We recommend using a butterfly.

Step 2: Add a File

If you want to add a new file to your codebase, you will need to tell Git about it. Otherwise, Git will not track the file.

git add _path_to_file_

To find out if you have any files in your local clone that Git isn't yet tracking, run:

git status

Any pending changes and files to be added will be listed like this:

Git Status

You can then cut and paste the paths to these files when using git add .

Push Changes to Pantheon

Sending code to Pantheon is a two step process with Git. First, you need to commit the files locally. Then you need to "push" them to the Pantheon cloud.

Step 1: Commit the Files Locally

In order to tell Git the files are ready, you need to commit them. Every commit includes a brief message so you can later remember why the change was made. It is worthwhile to take a moment and create an accurate commit message to help others understand your changes.

git commit -am "Add a great new module to increase awesomesauce level of my Drupal site."

This command uses a combination of options -am: -a to include all files changed, and -m to include a commit message:

If you don't specify a message on the command line, Git will open your default text editor and prompt you to create one. Exiting without making a message will abort the commit. If the commit worked you will see something like this:

Git Commit

There is a handy list of Git commands (along with a lot of other documentation) on GitHub.

Step 2: Send the Changes to Pantheon

You have committed the file locally, but you still need to send the changes to Pantheon. To do this, use the push command:

git push origin master

This executes a push to the origin location, which is Pantheon since that's where you cloned the code from, on the branch "master", which is what your Dev environment tracks.

If you have a password on your SSH key, you may need to enter it to authorize the push. If everything worked, you will see something like this:

Git Push

Step 3: View the Changes on Pantheon

When the push command completes, Pantheon instantly deploys the changes to your development server.

Go back to your site's Dev tab in Pantheon, click the URL under "Development site", and browse to your changes.


Authenticity & Fingerprint Prompts

Initial connections from your local computer to a site's codebase on Pantheon after running git commands will prompt you to confirm the connection:

The authenticity of host '[]:2222 ([IP.ADDRESS]:2222)' can't be established.
RSA key fingerprint is SHA256:yPEkh1Amd9WFBSP5syXD5rhUByTjaKBxQnlb5CahZZE.
Are you sure you want to continue connecting (yes/no)?

You can safely type yes and press enter to add the server's SSH key fingerprint to your computer's known_hosts file. Additional connections to this specific Pantheon container will complete successfully without prompts. However, you will be prompted to confirm connections following a container migration, which is part of regular maintenance on the platform. See the following Pro Tip to automatically accept all Pantheon connections.

Checking Out Code using GUI Clients

SourceTree and other Git GUI clients generally prompt for a Source URL using HTTP or HTTPS to the repository to check out the site code. Pantheon does not provide Git repository access over HTTP(s), and instead provides a "Git over SSH" URL. For example:

git clone ssh:// my-site

Some Git GUI clients, like SourceTree, do support the use of ssh:// URLs to clone the code base.

To configure this URL in SourceTree simply remove the git clone and the trailing space and 'my-site' name off the end of the command provided in the Connection Info section of your Pantheon Dashboard.

  • Source URL: ssh://
  • Destination Path: The local path where you want to clone the repository.
  • Name: Your site name.

SourceTree git Configuration

Alternatively, you can simply clone the repository using the git clone and then use the "Add Existing Local Repository" option in SourceTree to point to the checked out directory.

Blocked port

If your local network is blocking port 2222, you'll see an error like this when attempting to run git clone, git push, or git pull:

ssh: connect to host port 2222: Operation timed out
fatal: Could not read from remote repository.

To clear this up, you may need to work with your network administrators to unblock this port. If this isn't an option, you may need to try a Port 2222 Blocked Workaround.

Additional Resources

For further learning, we recommend the following resources:

For Pantheon-specific Git questions, see the following: