Basic Syntax

The GitCentric CLI commands are executed as SSH remote commands, which require that you have an SSH client installed. The syntax for a GitCentric CLI command executed from SSH is:

ssh -p <port> <user>@<host> gitcentric [<command>] [[<arg>]...]] [--help] [--]
<port> GitCentric port number, typically 29418.
<user>@<host> The SSH user account used with GitCentric (for example myusername@localhost).
<command> May be one of the following:
  • config-branch
  • config-repo
  • delete-repo
  • ls-repo
<arg> One or more arguments to pass to <command>. These vary based on command.
--help, -h Displays the on-line help for the current command. Specifying --help with no other arguments (for example, gitcentric --help) returns a list of all available sub-commands.
--

Specifies that the rest of the command line is to be considered arguments, not options. For example, if you need to pass a repo name that starts with - you would precede it with --. After using --, you cannot pass any further options on that command line.

For example:

...config-repo Repo1 Repo2 -- -Repo3 Repo4 -Repo5

Back to top

Spaces and Quoting

To include a space in arguments for a GitCentric SSH command, you must use quotes.

In addition, Microsoft Windows requires that you nest single quotes within double-quotes. In the example below, double-quotes are provided for the Microsoft Windows shell, and single-quotes are nested within the double-quotes for the SSH command-line parser.

C:\source\TestProject>ssh -p 29418 mylogin@localhost gitcentric
config-branch --branch refs/heads/master -p 1 -e 3 -s 2
-d "'xxxx yyyy'" --initialSync git TestProject

Back to top

CLI example

This example walks you through the entire process of creating a repository, cloning it, populating it with content, pushing, and finally mapping one of its branches to an AccuRev stream, all through Git, Gerrit, and GitCentric CLI commands.
  1. Create a repository with an initial empty commit:
    ssh -p 29418 yourUsername@yourServer gerrit create-project --empty-commit repoName
  2. Register the repo with GitCentric and associate it with an AccuRev Server:
    ssh -p 29418 yourUsername@yourServer gitcentric config-repo repoName
    -S 10.0.0.182:5050 -u syncUser -p syncUserPassword
  3. Clone the repo.
    git clone ssh://yourUsername@yourServer:29418/repoName repoName
  4. Change to the new clone’s directory and configure it:
    cd repo_tues2
    git config user.name "Firstname Lastname"
    git config user.email "f.lastname@yourdomain.com"
    git config remote.origin.push refs/heads/*:refs/for/*
  5. Using your preferred text editor, create a file in the clone.
  6. Add, commit, and push the file:
    git add --all
    git commit --all -m"First commit"
    git push

    Note: This step creates branch master, which must exist before the next step.

  7. Map the master branch to a stream named agc_devel on the AccuRev Server:
    ssh -p 29418 yourUsername@yourServer gitcentric config-branch repoName
    -b master -s streamName -e /
  8. Display a listing showing the mapped repo:
    ssh -p 29418 yourUsername@yourServer gitcentric ls-repo

Back to top