Support / KnowledgeBase

 
Search the KnowledgeBase Search

Using Git

  • Applies to: Grid

  • Difficulty: Hard

  • Time needed: 30 minutes

  • Tools needed: SSH, vi knowledge

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

Overview

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 example.com 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.

READ ME FIRST

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

Instructions

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.

NOTE:

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-6) are performed on your local machine:

  1. Add an alternate or subdomain to your service through the AccountCenter. For this article, we will use the descriptive name 'git.example.com'.
  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 example.com@example.com:domains/git.example.com/html/example.git
    
  6. Log into your Grid to complete the setup using SSH:
    ssh example.com@example.com
    cd domains/git.example.com/html/example.git
    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

Pulling

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

git clone http://git.example.com/example.git

Pushing

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://example.com@example.com/home/00000/domains/git.example.com/html/example.git 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://example.com@example.com/home/00000/domains/git.example.com/html/example.git

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.

Resources

 

Continue