Welcome, Guest! Log In | Create Account

What is Git?

Git is a Source Code Management (SCM), a tool for software developers which supports collaborative development of software within a team, and the tracking of changes to software source code over time.

Git is used by developers, and advanced users who need the very latest changes to the software (before releases occur). Software users generally do not need Git; typically they will download official file releases made available by the project instead.

Developers should familiarize themselves with Git by reading the Git Documentation.

Features

SourceForge.net provides the following features in its Git offering:

Management

Git service may be enabled for your project as follows:

  1. Login as a project administrator and go to the Develop page for your project.
  2. From the Project Admin menu, select Feature Settings
  3. Select the Available Features tab
  4. Check the box for Git; your repository will be instantly enabled, and the heading for Git should move from the Available Features tab to the Enabled Features tab.

Once Git has been enabled, you may wish to adjust permission grants for your users, if you need to disable one or more user's ability to make changes in the git repository.

The standard way to modify the contents of your repository is using a Git client as detailed in the Git User's Manual. Refer to the Getting Started section for how to make your first commit to your new repository.

Administrators may also manually manipulate their repository via the site interactive shell service.

We strongly recommend that when modifying a repository, other committers be notified of the direct edit window and that you make your own backups prior to editing the content so you can restore it readily yourself in the case of an accident.

Access

To access a Git repository, configure your Git client as follows (replace PROJECTNAME with the UNIX group name of the project, and REPONAME with the name of the git repository):

  • git://PROJECTNAME.git.sourceforge.net/gitroot/PROJECTNAME/REPONAME (read-only)
  • ssh://USERNAME@PROJECTNAME.git.sourceforge.net/gitroot/PROJECTNAME/REPONAME (read/write)

The default repository name is the same as the project's UNIX group name, e.g

  • git://PROJECTNAME.git.sourceforge.net/gitroot/PROJECTNAME/PROJECTNAME

For those developers who have git access enabled to more than 16 projects, you may need to include your PROJECTNAME as a part of the USERNAME (appended after a comma) in order to work around a Linux permission limitation:

  • ssh://USERNAME,PROJECTNAME@PROJECTNAME.git.sourceforge.net/gitroot/PROJECTNAME/REPONAME (read/write)

Authentication

The read-only access does not prompt for a password.

The read/write access uses your ssh password or ssh key to authorize your access. To perform write operations, your project administrator must have granted you write access to the repository.

Getting Started

Your project's Git repository will be completely empty at the start, and older Git releases do not allow a repository with no content to be cloned. What you will do instead is to push a Git repository that you create (or have previously created) from your own system to our servers. Since Git is a distributed version control system, having a copy of the full repository on your local system is the normal way things work.

Note that starting with git 1.6.2, you can now simply "git clone" your empty repository, and it will warn you about the emptiness and leave you with a repository that has the origin and branch settings (described below) already set for you.

How to create a new repository

Note: - For all examples below, "PROJECTNAME" represents a SourceForge.net project UNIX name and "USERNAME" represents your SourceForge.net user account.

Create an empty repository like this:

mkdir PROJECTNAME
cd PROJECTNAME
git init

Setting your git username

Users should commit to their project repository using their SourceForge.net username. If that is not already set globally, you can set it locally for the current Git repository like this:

git config user.name "YOUR NAME"
git config user.email "USERNAME@users.sourceforge.net"

You can now use some combination of "git add" and "git commit" commands to create one or more commits in your local repository.

How to push a local repository

Before you push your files, you need a local Git repository. You can either create one from scratch, convert a repository (e.g. via git-cvsimport or similar), or start with a copy of an existing Git repository.

For any local Git repository, you can configure it to push data back to our server by doing the following from inside your Git repository (this replicates what a "git clone" from our servers sets up for you automatically):

git remote add origin ssh://USERNAME@PROJECTNAME.git.sourceforge.net/gitroot/PROJECTNAME/REPONAME
git config branch.master.remote origin
git config branch.master.merge refs/heads/master

Now you're ready to push the committed files to our servers:

git push origin master

Note: The use of "origin master" prevents Git from complaining that the remote server has no branches in common with your local repository (which is true at the start when the remote repository is completely empty), and "master" is the default branch in Git.

After the first push, you will be able to use the simpler "git push" to push the master branch to our "origin" server.

Once that is done, you will be able to browse your newly-committed content via gitweb, clone the repository via either read-only or read/write access methods, push more check-ins, etc.

Creating Multiple Repositories

To create a new repository, you need to access the Shell service, then follow these steps:

  1. Navigate to your repository
    1. cd /home/scm_git/P/PR/PROJECTUNIXNAME
      • PROJECTUNIXNAME is the UNIX name of your project
      • P represents the first letter of that name, and PR the first two letters of the name.
  2. Create a new directory with the name you want for the repository, eg mkdir DIRNAME.
  3. Run git --git-dir=DIRNAME init --shared=all --bare (where DIRNAME represents the name of the repository to be created)
    • This will initialize a new repository at that directory

Notes: Developers should not nest directories / repositories. Directories should only be created the top level directory of repository. Be sure to make backups prior to editing your repository contents.

Backups

SourceForge.net performs routine backups for all of our servers and will restore from these backups in the event of catastrophic server failure. We encourage projects to make their own backups of Git data as that data restore can be performed by the project in the event of accidental data destruction by a member of the project team.

Backups of a Git repository may be made using rsync.

Example (replace PROJECTNAME with the UNIX group name of your project):

rsync -av PROJECTNAME.git.sourceforge.net::gitroot/PROJECTNAME/* .

Getting Help


Initial draft finished 2009-02-18