Git Repositories

Introduction

Git is a distributed version control system originally developed by Linus Torvalds for Linux kernel development. Over the years, it has become the version control system of choice for many very active open source projects.

This guide assumes that you have already installed the latest Git client onto your development machine.

Authentication

Repository Hosting offers you three methods for accessing your Git repositories. If the repository is public, users may clone the repository using the proprietary Git protocol (git://). For private repositories, or public repositories to which you are committing, users may access the repository over SSH (ssh://) or HTTP (http:// or https://). SSH is generally faster, but you might need to use HTTP to get through a corporate firewall. When using HTTP, you must provide the same account credentials you use to access the Repository Hosting web interface.

Repositories accessed over SSH require the use of a public keypair. For more information on how to create a keypair and use it with Repository Hosting, please reference Generating an SSH Keypair.

There are also two ways you may view your repository directly from your browser. You may view it in Trac using the "Browse Source" tab, or you can access the "GitWeb" interface by going to the HTTP repository URL in your browser.

Repository Creation and Importing

When you first create a Git repository from the Repository Hosting web interface, it will be empty (and not able to be cloned). To begin using it, you must first create a local Git repository, commit locally to it, and then push your changes to the upstream server.

To create the repository locally, do the following:

$
$
$
mkdir myproject
cd myproject
git init

Now that the repository has been created and initialized, you must now associate it with the one hosted by Repository Hosting (the upstream repository). This can be done as follows (being sure to replace mysubdomain and myproject with the appropriate values):

$
$
git remote add origin ssh://git@mysubdomain.repositoryhosting.com/mysubdomain/myproject.git
git config remote.origin.push refs/heads/master:refs/heads/master

Now you can begin to commit locally to your repository. Copy your project files into the directory, add them to the index, then commit.

$
$
git add *
git commit -am 'initial commit'

Finally, you can now push your local commits up to the currently empty Repository Hosting Git repository.

$
git push origin master

After a short while, your first commit should be complete. Now you should be able to view your repository from the Repository Hosting Trac web interface online.

Cloning

Once your repository has been populated with at least one commit, other users with access to the repository can clone it.

$
git clone ssh://git@mysubdomain.repositoryhosting.com/mysubdomain/myproject.git

To clone via HTTPS:

$
git clone https://mysubdomain.repositoryhosting.com/git/mysubdomain/myproject.git

To clone a public repository:

$
git clone https://mysubdomain.repositoryhosting.com/git_public/mysubdomain/myproject.git

NOTE: It is not possible to clone an empty repository. You must first push data into the repository and only then can it be cloned.

Further Reading

There is now a vast amount of information available on how best to use Git. For starters, we suggest the following: