Project Creation

There are several ways to create a new project in Gerrit:

To be able to create new projects the global capability Create Project must be granted.

In addition, projects can be created manually.

Manual Project Creation

  1. Create a Git repository under gerrit.basePath:

      git --git-dir=$base_path/new/project.git init
    Tip
    By tradition the repository directory name should have a .git suffix.

    To also make this repository available over the anonymous git:// protocol, don’t forget to create a git-daemon-export-ok file:

      touch $base_path/new/project.git/git-daemon-export-ok
  2. Register Project

    Either restart the server, or flush the project_list cache:

      ssh -p 29418 localhost gerrit flush-caches --cache project_list

Project Options

See details at project section.

Branch Administration

Branch Creation

There are several ways to create a new branch in a project:

  • in the Web UI under 'BROWSE' > 'Repositories' > <project> > 'Branches'

  • via the Create Branch REST endpoint

  • via the create-branch SSH command

  • by using a git client to push a commit to a non-existing branch

To be able to create new branches the user must have the Create Reference access right.

When using the Web UI, the REST endpoint or the SSH command it is only possible to create branches on commits that already exist in the repository.

If a branch name does not start with refs/ it is automatically prefixed with refs/heads/.

The starting revision for a new branch can be any valid SHA-1 expression, as long as it resolves to a commit. Abbreviated SHA-1s are not supported.

Branch Deletion

There are several ways to delete a branch:

  • in the Web UI under 'BROWSE' > 'Repositories' > <project> > 'Branches'

  • via the Delete Branch REST endpoint

  • by using a git client

      $ git push origin --delete refs/heads/<branch-to-delete>

    another method, by force pushing nothing to an existing branch:

      $ git push --force origin :refs/heads/<branch-to-delete>

To be able to delete branches, the user must have the Delete Reference or the Push access right with the force option.

Default Branch

The default branch of a remote repository is defined by its HEAD. The default branch is selected from the initial branches of the newly created project, or set to host-level default, if the project was created with empty branches. For convenience reasons, when the repository is cloned Git creates a local branch for this default branch and checks it out.

Project owners can set HEAD several ways:

  • in the Web UI under 'BROWSE' > 'Repositories' > <project> > 'Branches'

  • via the Set HEAD REST endpoint

  • via the Set HEAD SSH command