2. How to... : Create a Clone From a GitCentric Repository
   
Create a Clone From a GitCentric Repository
The procedure for creating a local clone from a GitCentric repository is a basic Git operation:
1. git clone ssh://<gitCentricLogin>@<gitCentricServer>:<port>/<repoName> <cloneName> where:
<gitCentricLogin> is the AccuRev username you specified in Log In to GitCentric on page 14.
<gitCentricServer> is the host where GitCentric is installed (the same you specify in the URL in Log In to GitCentric on page 14.
<port> is the SSHD listener port (typically 29418).
<repoName> is the name of the GitCentric repo.
<cloneName> is the 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 registered with GitCentric in Register with GitCentric on page 16, or else git push operations will fail.
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:
git config remote.origin.push 'refs/heads/*:refs/for/*'
This causes files to be pushed to a special branch for code review.
Next, 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> is the SSHD listener port (typically 29418)
<server> the 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 Configure Access Rights (ACLs) for a Repo on page 34.)
Configure the Clone for Direct Push
If your site does not use the GitCentric’s optional Gerrit Code Review functionality, you must ensure that the line push = refs/heads/*:refs/for/* (added by the git config command described in the previous section) does NOT appear in the [remote "origin"] section of your clones’ config file.
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.