Using Git

  • Applies to: Grid
  • Applies to: Managed WordPress
    • Difficulty: Hard
    • Time Needed: 30
    • Tools Required: SSH, vi knowledge

Using Git with a Hosted Repository


This article is provided as a courtesy. Configuration of third-party software is not covered by (mt) Media Temple's Statement of Support. Please take a moment to review the Statement of Support.

Setting up your repository

This KnowledgeBase article assumes that you already have your repository set up in Github. For instructions on using Github, please see the following guide:


Connecting via SSH

Once you have your Github or Gitlab repository configured, you can begin configuring Git on your Managed WordPress installation. Start by connecting to your Managed WordPress site via SSH:

Setting up Git

  1. Once connected, you'll be in your WordPress home directory. You can initialize Git in the home directory by using the following command:
    $ git init

    This will create /home/user123456789/.git/  

  2. Set your Github username and email address.
    $ git config --global "YourUsernameHere"
    $ git config --global
    TIP: If you don't know your Github account email address, you can find it in Account Settings > Emails on Github
  3. Create your SSH key.
    1. Run the following command. Make sure to use your Github email address.
      $ ssh-keygen -t rsa -C
    2. You will be prompted for a location to save the SSH key. The default setting is the correct one, so simply press Enter at this prompt.
    3. You will be prompted for a passphrase, which you should enter, then press Enter. Nothing will show on the screen while you are typing, but it will take your input nonetheless.
    4. If successful, you will see some output confirming that the key has been saved, including a line similar to the following, which indicates the location of the public key file.
      Your public key has been saved in /home/user1234567890/.ssh/
    5. Print the key to your terminal using the 'cat' command. Be sure to use the actual location of the public key.
      $ cat /home/user1234567890/.ssh/
    6. Copy the output. Add this to your Github account in Account Settings > SSH Keys > Add Key
  4. Since Media Temple manages the core WordPress installation for you as part of the Managed WordPress service, you will only be able to use Git to manage plugins, themes, uploads, and other custom content. You will need to use a custom .gitignore file to prevent Git from attempting to write to the core WordPress files.

    Start by opening the .gitignore file.

    $ vim .gitignore
    Add the following lines to this file. You can enter insert mode in vim by hitting the i key.
    Exit insert mode by hitting Esc. Save and quit by typing :wq.


  5. Add the remote repository to Git using the following command structure. Replace username� with your actual Github username, and repo.git with the actual repository.
    $ git remote add origin
  6. In order to make Git to work correctly, it's best to tell it to use SSH.
      1. Start by editing .git/config.
    $ vim .git/config
    1. Look for the following section:
      [remote "origin"]
              url =
    2. Navigate down to the url line with the arrow keys, and use i to enter Insert mode. Change it to match the following, where the email address is your Github email address and the username is your Github username.
      [remote "origin"]
              url = ssh://
    3. Once this change has been made, exit Insert mode with Esc and Save/Quit by typing :wq
  7. Finish by running the following commands:
    git add .
    git commit -m initial commit
    git push -u origin master
  8. That's it! You're now ready to use Git!
This KnowledgeBase article is only meant to cover the initial set-up of Git on your Managed WordPress site. You can find additional information at


Git is a free and open source, distributed version control system designed to handle everything from small to very large projects with speed and efficiency.

Git falls in the category of distributed source code management tools, similar to CVS, Subversion (svn), or Bazaar. Every Git working directory is a full-fledged repository with complete history and full revision tracking capabilities, not dependent on network access or a central server. Still, Git stays extremely fast and space efficient.

This article will focus on using Git with a subdomain on your Grid.

Before you start

This article has the following dependencies:

  • Whenever installing third-party software, please consult the official documentation. (mt) Media Temple does not support the installation and configuration of software not installed at time of service activation. Please consult our Grid Scope of Support page for further explanation.
  • The domain is used as an example. Please be sure to replace this text with the proper information for your site or server.
  • This article assumes that you have already set up Git locally on your own computer. Due to the diversity of desktop computer platforms, this article does not cover the steps to get it set up locally.


This article is provided as a courtesy. Installing, configuring, and troubleshooting third-party applications is outside the scope of support provided by (mt) Media Temple. Please take a moment to review the Statement of Support.

The following Git packages are installed on the Grid:

  • git-core
  • git-doc
  • git-email
  • gitweb
  • git-svn

These packages provide core Git functionality as well as the ability to browse repository information on the web and bridge Git with Subversion.

Current version

You can the following command to view the current version installed on your Cluster:

git --version


Creating a repository for use on your Grid subdomain

The normal workflow, when using Git, is saving your work to a local repository on your personal computer and, when ready for publishing, "pushing" those changes to your "bare" repository. Here are the steps needed for this process.


Remember that this article assumes your are using a Unix environment, such as OS X, on your personal computer. If you are using Windows, please substitute the usage of the following commands to match your local environment.

The following steps (1-5) are performed on your local machine. The commands in step 6 require you to connect to the Grid via SSH

  1. Add an alternate or subdomain to your service through the AccountCenter. For this article, we will use the descriptive name ''.
  2. On your personal computer, make a directory and create your bare repository.
    mkdir example && cd example
    git init
  3. Now create a meaningless test file that we will commit to the local repository:
    touch .gitignore
    git add .gitignore
    git commit -m "just adding test gitignore file"
  4. Create the "bare" clone named example.git:

    Before we can push our local Git repository to the Grid, we have to create a bare clone. A default Git repository assumes that you'll be using it as your working directory, so Git stores the actual bare repository files in a .git directory alongside all the project files. Remote repositories do not need copies of the files on the filesystem unlike working copies. This is what "bare" means to Git -- just the repository itself.

    cd ..
    git clone --bare example example.git
    touch example.git/git-daemon-export-ok
  5. It's now time to upload the repository to your Grid using scp. Please make sure ssh is enabled in the AccountCenter:
    scp -r example.git
  6. Log into your Grid to complete the setup using SSH:
    cd domains/
    git --bare update-server-info
    cd hooks
    mv post-update.sample post-update
    chmod a+x post-update

Your repository is now configured!! At this point, you and your contributors will now be able to push and pull content to your new repository.

Using your repository


New users can clone your repository directly from the Grid to another machine using http with the following command:

git clone


Now that we have a working repository both locally and on the Grid, we can start using git to "push" new content. Assuming you have added/updated new files locally you would use the following command to update your repository on the Grid from within your local example directory:

git push ssh:// master

Of course, this is a lengthy command to use every time you want to push your files. You can actually create a shortcut for the above using the Git remote add function. The following command matches up to the one above and uses the word "grid" as the shortcut name. Make sure you are in your local example directory first before running this command:

git remote add grid ssh://

Now you can simply push using the command:

git push grid master

For more information about public Git repositories, see this page in the Git user manual.

For more information, see the INSTALL documentation for gitweb.


Was this article helpful?
1 out of 1 found this helpful
Have more questions? Submit a request


Powered by Zendesk