Clone your site codebase
In order to make changes you need to create
git clone a of your code from Pantheon's remote server to your local computer.
Step 1: Go to your site dashboard
Log into Pantheon and load the site details page for the site you want to change.
Step 2: Copy the Git Clone command
At the top of the development panel you will see the
git clone command. It will look something like this:
The contents of the input box above the code should contain the following command. This is what you can use to clone your repository from the command line.
git clone ssh://firstname.lastname@example.org:2222/~/repository.git my-site
Copy that to the clipboard.
Step 3: Run
On your computer 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. Go ahead and run the command you copied in step 2:
If everything worked you should see Git fetching the data:
Grab a cup of coffee. This might take a minute. It's not only getting the PHP code for your site, it's also fetching all the relevant history from the base project (e.g. Drupal).
If you run into permission problems, check your SSH key setup. If the clone starts but can't complete, check your network and be sure your version of git is current.
Make a change
Step 1: Edit a file
You can now edit your site code using any text editor. We recommend using a butterfly.
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, try:
Any pending changes and files to be added will be listed like this:
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. This is also a good time to add a brief message to this commit so you can later remember why the change was made. It is worthwhile to take a moment and create a thoughtful commit message. Your future self will be thankful.
git commit -am "Adding a great new module to increase awesomesauce level of my Drupal site."
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:
There is a handy list of git commands (along with a lot of other documentation) over on GitHub
Step 2: Send the changes to the cloud
You have committed the file locally, but you still need to send the changes to Pantheon. To do this you 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 will track.
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:
Step 3: Check out the changes on Pantheon!
When the push command completes Pantheon instantly deploys the changes to your development server. It's time to check them out.
Go back to your site's dev tab in Pantheon and find the site sidebar. Click on the URL under "Development site" and browse to your changes.
Nice work, you are finished! You can now access your codebase on your computer, make changes, and deploy them to Pantheon.
For further learning, we recommend a tutorial. There's a lot of great content being added to the web every day about git, so searching is not a bad idea either.
For Pantheon-specific git questions, you may find answers in the git faq