...
- Set your username for your account. This can be any username, although we highly recommend matching your Atlassian username.
- Add your SSH public key.
Cloning from Gerrit
While access to the underlying git repository is open to anyone via anonymous HTTP access, this guide will assume that you want to push changes up as well. For that, Gerrit uses SSH. If you are only looking to obtain the source code for a particular repository, you may just use the HTTP methods shown below.
- Clone the repository:
SSH:
Code Block $ git clone ssh://{user}@gerrit.asterisk.org:29418/{repo}
HTTP:
Code Block $ git clone http://{user}@gerrit.asterisk.org/{repo}
Anonymous HTTP:
Code Block $ git clone http://gerrit.asterisk.org/{repo}
Copy the
commit-msg
hook into your local.git/hooks
folder:Code Block $ scp -p -P 29418 {user}@gerrit.asterisk.org:hooks/commit-msg {local-repo}/.git/hooks/
The
commit-msg
hook adds theChange-Id
automatically to git commit messages. AChange-Id
is necessary for Gerrit to associate multiple patch sets together. For more information, see Change-Ids.
Pushing to Gerrit
...
Pushing to Gerrit for code review is done by pushing to the refs/for/[branch]
. Generally, this will be master
, unless pushing to a particular mainline Asterisk branch.
Code Block |
---|
$ git push ssh://{user}@gerrit.asterisk.org:29418/{repo} HEAD:refs/for/master |
...
Creating an SSH Alias
Since access to gerrit.asterisk.org is likely to occur often, you may want to set up an SSH alias:
Code Block |
---|
$ cat ~/.ssh/config
...
Host asterisk
Hostname gerrit.asterisk.org
Port 29418
User {user} |
This
...
will allow you to
...
access the repository as shown below:
Code Block |
---|
$ git clone asterisk:{repo} |
Pushing to Gerrit for Code Review
Use git review
Install
git-review
:Code Block $ pip install git-review
To submit a change to
master
:Code Block $ git review
To submit a change for a particular branch:
Code Block $ git review {branchname}
To submit a change, including the
ASTERISK
issue:Code Block $ git review -t ASTERISK-12345
Use git push
Pushing to Gerrit for code review can always be done using standard git
commands. This is done by pushing to the refs/for/[branch]
. Generally, this will be master
, unless pushing to a particular mainline Asterisk branch.
Code Block |
---|
$ git push asterisk:{repo} HEAD:refs/for/master |
Updating a Review
Reviews are automatically updated so long as commits contain the same Change ID. If your review has any findings, rebase the commits as appropriate, making sure the Change ID is preserved:
Code Block $ git rebase -i HEAD~{num}
Re-push the changes:
Code Block $ git review
or:
Code Block $ git push asterisk:{repo} HEAD:refs/for/master
...