Working with clones

This section describes how to work with a clone of the GitCentric repository.

Create a clone from a GitCentric repository

To create a local clone from a GitCentric repository:

  1. Run the following command:
    git clone ssh://<gitCentricLogin>@<gitCentricServer>:<port>/<repoName> <cloneName>

    where:

    <gitCentricLogin> AccuRev username you specified in Log in.
    <gitCentricServer> Host where GitCentric is installed.
    <port> SSHD listener port (typically 29418).
    <repoName> Name of the GitCentric repo.
    <cloneName> Name of the clone you are making of GitCentric repo.

    Notes about repo and clone names:

    • Typically <repoName> and <cloneName> will be the same, but they do not need to be.
    • If the repo has a .GIT extension, you do not need to specify it in this command.
    • By convention, only bare repos have a .GIT extension. Working repos do not. In general, you should not specify .GIT extensions when working with GitCentric.
  2. Prepare to configure the clone:
    cd <cloneTopDirectory>
  3. Configure your username:
    git config user.name "<yourRealName>"
  4. Configure your email address:
    git config user.email "<yourEmailAddress>"

    Note: This must be the same as your Preferred Email as referenced in Register with GitCentric, or else git push operations will fail.

Back to top

Configure the clone for Code Review (optional)

If you will be using GitCentric’s optional Gerrit Code Review functionality as part your development, you must configure your clone as follows:

  1. Enter:
    git config remote.origin.push 'refs/heads/*:refs/for/*'
    This causes files to be pushed to a special branch for code review.
  2. Copy the commit-msg hook to the .git/hooks/ directory of each clone. For example:
    scp -p -P <port><server>:hooks/commit-msg .git/hooks/

    where:

    <port> SSHD listener port (typically 29418).
    <server> Host where GitCentric is installed.

If you will not be using Gerrit Code Review, and you are pushing directly to the repository, then leave this step out. In either case, ensure that your GitCentric administrator has set push and other ACL permissions correctly for either the Gerrit Code Review or direct push environment. See Repository Access Rights (ACLs).

Back to top

Configure the clone for direct push

If your site does not use the GitCentric’s optional Gerrit Code Review functionality, you must configure the clone for direct push and ensure that the following line:

push = refs/heads/*:refs/for/*

(added by the git config command described in Configure the clone for Code Review (optional)) does not appear in the [remote "origin"] section of your clones’ config file.

Back to top

Troubleshoot Git clone issues

If you have a problem cloning a repository, or using it once it has been created, check the following:

  • Ensure that the user has gone through initial GitCentric login and has the correct username, email, and ssh.
  • Test the ssh configuration with this command:
    ssh -p 29418 <gc_user>@<gitCentricServer> gitcentric --help

    This should return a usage message that refers to the config-branch, config-repo, and ls-repo commands. If the command returns an error message, ssh has not been set up correctly. In this case, try the command again using a -v switch to obtain additional messages that might be useful for debugging.

  • Make sure that the path in the git clone call is correct.
  • If you have an authorization error, have an administrator check the ACLs in Administration > Repositories > <repoName> > Access.
  • Have an administrator check the bare repo in the GitCentric storage directory. Use commands such as git log, git branch, and git cat-file –p master. If it is empty, check the log files for initial import/export failure.

Note: Git does not track empty directories although AccuRev does. Therefore, if you have empty directories in your AccuRev stream, these will NOT appear in a Git clone of a repository that is mapped to that AccuRev stream.

Back to top