Setting up Gerrit: Difference between revisions

From Qt Wiki
Jump to navigation Jump to search
(Convert ExpressionEngine links)
(→‎Local Setup: On MacOS Console is for viewing log files - Terminal gives you a command prompt)
(41 intermediate revisions by 19 users not shown)
Line 1: Line 1:
[[Category:Developing_Qt::Instructions]]
[[Category:Developing Qt::Instructions]]
[[Category:Tools::Gerrit]]


All projects under the Qt Open Governance umbrella are hosted on our [http://codereview.qt-project.org Gerrit Instance]. There is an [http://code.qt.io official mirror and browser] of these repositories.
All projects under the Qt Open Governance umbrella are hosted on our [http://codereview.qt-project.org Gerrit Instance].
There is an [http://code.qt.io official mirror and browser] of these repositories.
 
In order to be able to propose changes to those projects, you have to first setup your Gerrit account and get Qt's sourcecode, following the steps below:
# [[#How to get started - Gerrit registration|Set up]] a Gerrit account
# Tweak your SSH config as instructed [[#Local Setup|here]]
# Use the recommended Git settings, defined [[#Configuring Git|here]]
# [[#Getting the source code|Get the source code]] of the projects you want to contribute to
Moreover, if you did not use the init-repository scripts to get the source code, you will have to manually:
# [[#Setting up git hooks|Set up the git commit hooks]] .
# [[#Setting_up_gerrit_git_remote|Set up]] a Gerrit git remote.
 
Once all the steps above have been completed, you're ready to [[Qt Contribution Guidelines#Creating Changes for Inclusion Into Qt|submit your patch to Qt]]!
 
See also:
* [[Git Introduction]]
* [[Gerrit Caveats and Hints]]


== How to get started - Gerrit registration ==
== How to get started - Gerrit registration ==


# Create an account in the [https://bugreports.qt.io/ Qt bug tracker] (also known as JIRA)
# Create a [https://login.qt.io/register Qt account], if you don't have one yet.
# Go to https://codereview.qt-project.org and log in with your Qt bug tracker credentials
#* '''Note''': Use an all-lowercase user name. Otherwise, Gerrit will lowercase it for you, and as it is case sensitive, you will have to use mismatched login names.
#* '''Note''': Gerrit usernames are case-sensitive, but JIRA usernames are not. If you attempt to log into Gerrit with different capitalizations, you will end up with multiple accounts.
# Log into https://codereview.qt-project.org with your Qt account.
# Go to the Settings page: https://codereview.qt-project.org/settings/
# Go to [https://codereview.qt-project.org/#/settings/contact "Settings" -> "Contact Information"], set your real name and register your email address, if it hasn't been automatically registered.
# Go to "Settings" -> "Contact Information" and register your email address.
#* You will receive a confirmation email; click on the link inside to finalize your registration.
#* You will receive a confirmation email; click on the link inside to finalize your registration.
#** When you use Outlook, manually copy the link ''including any trailing equal signs'' into the browser.
#** If you use Outlook, manually copy the link ''including any trailing equal signs'' into the browser.
#* '''Note''': Your username and e-mail address will be visible to the public. Use an alias + a custom e-mail address if you want to stay anonymous (this is discouraged)
#* '''Note''': The email address you use to contribute to the Qt Project will be publicly visible in the Git history. Use an alias + a custom e-mail address if you want to stay anonymous (this is discouraged)
# Review and agree to the Qt Project's contribution license agreement (CLA) in Gerrit. You need to do this only once, unless the license changes.
#* If your company has a corporate contribution agreement, ask the admin of your company's Gerrit user group to add your account to this group.
#* More details about the CLA can be found [https://www.qt.io/contributionagreement/ here].
# Go to "Settings"-> "SSH Public Keys" and upload your [https://help.github.com/articles/generating-ssh-keys public SSH Key]
# Go to "Settings"-> "SSH Public Keys" and upload your [https://help.github.com/articles/generating-ssh-keys public SSH Key]
# If you are behind a firewall that blocks SSH access:
# If you are behind a firewall that blocks SSH access:
## Go to "Settings" -> "HTTP Password"
## Go to "Settings" -> "HTTP Password"
## Click "Generate Password"
## Click "Generate Password"
## Add the following line to your <tt>~/.netrc</tt> (Windows: <tt>​%USERPROFILE%netrc</tt>):<pre>machine codereview.qt-project.org login <Gerrit username> password <Generated password></pre>
## Add the following line to your <tt>~/.netrc</tt> (Windows: <tt>​%USERPROFILE%\_netrc</tt>):<pre>machine codereview.qt-project.org login <Gerrit username> password <Generated password></pre>


== Local Setup ==
== Local Setup ==
'''Proper configuration of SSH for your Gerrit account is necessary for the URLs in the next steps.'''


Configure SSH properly (the URLs below rely on this). Add this to your <tt>~/.ssh/config</tt> (Windows: <tt>C:USERNAME%sh\config</tt>):
Additionally, adding an SSH public key to your gerrit user account can be useful for custom applications that watch Gerrit for certain events and do things such as post automated comments, pull and build commits automatically, etc...


<pre>
The instructions below are applicable to Linux (Terminal), Mac (Terminal), and Windows (Powershell).
Host codereview.qt-project.org
Port 29418
User <Gerrit/Jira username>
</pre>


'''NOTE:''' The following steps need to be applied to every clone:
'''Note: SSH keys are intended to be unique to each machine. New keys must be created for each additional machine logging in to Gerrit with SSH.'''


Install the hook generating Commit-Id files into your top level project directory, as well as all sub-repositories (e.g. qtbase.git) either through
'''Note:''' On windows, the ~/ shorthand used below can be equated with <tt>C:\Users\%USERNAME%\</tt>. Make replacements in the example as necessary.


<pre>
# Edit "~/.ssh/config" with host information for gerrit. See sample below. Do not copy comments marked by #. They may not be ignored by your OS.  <syntaxhighlight>
$ scp -p codereview.qt-project.org:hooks/commit-msg .git/hooks
Host codereview.qt-project.org
</pre>
    Hostname codereview.qt-project.org
 
    Port 29418
or by downloading the file via browser: [http://codereview.qt-project.org/tools/hooks/commit-msg commit-msg] and putting it into the <tt>.git/hooks</tt> directory (make sure it is executable).
    # this is your Gerrit username, not email, and not your PC's username. You can view this from Settings in gerrit when logged in.
 
    User yourgerritusername
It is recommended to install the git_post_commit_hook from the [https://qt.gitorious.org/qt/qtrepotools qtrepotools] repository. This gives you the checks of the [[Early Warning System|Sanity Bot]] locally. To do this, save the script
    PreferredAuthentications publickey
<pre>
    IdentityFile ~/.ssh/id_rsa
#! /bin/sh
</syntaxhighlight>
exec "<path to git clone>/qtrepotools/git-hooks/git_post_commit_hook" "$@"
# Generate your key pairs with the ssh-keygen tool following the format below. Use Powershell in windows, Terminal in linux, or Console in Mac.  <br>ssh-keygen -t rsa -b 4096 -C youremail@email.com -f ~/.ssh/id_rsa
</pre>
# Log into codereview.qt-project.org and navigate to Settings → SSH Public Keys
into each <path to git clone>/.git/hooks/post-commit
# From the ~/.ssh directory, open the newly created id_rsa.pub file with a text editor.
 
# Copy the entire contents and paste into a new key entry in you Gerrit's SSH Public Keys page.
'''NOTE:''' Starting with git 1.7.8, if <tt><module name>/.git</tt> contains <tt>gitdir: ../.git/modules/<module name></tt>, you need to put the submodule hooks in <tt>.git/modules/<module name>/hooks</tt> instead of <tt><module name>/.git/hooks</tt>.
# Save the new entry in your Gerrit settings.
# You can test to verify the connection works by running: ssh codereview.qt-project.org gerrit stream-events
# If the connection is functional, every Gerrit event should be displayed in raw format to your console.


== Configuring Git ==
== Configuring Git ==
Line 53: Line 71:


<pre>
<pre>
$ git config --global core.autocrlf true
git config --global core.autocrlf true
</pre>
</pre>


Line 59: Line 77:


<pre>
<pre>
$ git config --global core.autocrlf input
git config --global core.autocrlf input
</pre>
</pre>


Line 67: Line 85:


<pre>
<pre>
$ git config --global user.name "Your Name"
git config --global user.name "Your Name"
$ git config --global user.email "me@example.com"
git config --global user.email "me@example.com"
</pre>
</pre>


Line 74: Line 92:
Gerrit will not accept your commits unless the committer information matches the email address(es) you registered.
Gerrit will not accept your commits unless the committer information matches the email address(es) you registered.


To facilitate following the style guide for commit messages, it is recommended to install the Qt commit message template:
To facilitate following the style guide for commit messages, it is recommended to install the Qt commit message [http://code.qt.io/cgit/qt/qt5.git/tree/.commit-template template]:


<pre>
<pre>
$ git config --global commit.template <path to qt5.git or qt.git>/.commit-template
git config --global commit.template <path to qt5.git or qt.git>/.commit-template
</pre>
</pre>


Line 83: Line 101:


<pre>
<pre>
$ git config --global status.showuntrackedfiles all
git config --global status.showuntrackedfiles all
</pre>
</pre>


Line 89: Line 107:


<pre>
<pre>
$ git config --global push.default tracking
git config --global push.default tracking
</pre>
</pre>


Line 97: Line 115:


<pre>
<pre>
$ git config --global rerere.enabled true
git config --global rerere.enabled true
$ git config --global rerere.autoupdate true # this saves you the git add, but you should verify the result with git diff --staged
git config --global rerere.autoupdate true # this saves you the git add, but you should verify the result with git diff --staged
</pre>
</pre>


Line 104: Line 122:


<pre>
<pre>
$ git config --global rebase.stat true
git config --global rebase.stat true
</pre>
</pre>


Line 110: Line 128:


<pre>
<pre>
$ git config --global color.ui auto
git config --global color.ui auto
$ git config --global core.pager "less -FRSX"
git config --global core.pager "less -FRSX"
</pre>
</pre>


Line 117: Line 135:


<pre>
<pre>
$ git config --global alias.di diff
git config --global alias.di diff
$ git config --global alias.ci commit
git config --global alias.ci commit
$ git config --global alias.co checkout
git config --global alias.co checkout
$ git config --global alias.ann blame
git config --global alias.ann blame
$ git config --global alias.st status
git config --global alias.st status
</pre>
</pre>


=== Using Existing clones ===
== Getting the source code ==
 
=== Cloning Qt5 ===
You should clone from the [http://code.qt.io/ official mirror] and track changes from there in order to keep the load on Gerrit down.
 
This [[Building-Qt-5-from-Git|guide]] will show you how to get and build the source code.
 
After getting the source code, if you did not use the init-repository script to clone the source code as described in the guide, or you want to manually clone only a submodule, make sure you also [[#Setting up git hooks|manually set up the git commit hooks]] and [[#Setting up gerrit git remote|set up a git remote that point to Qt's gerrit instance]].


Add a <tt>gerrit</tt> remote pointing to codereview.
=== Cloning Qt Creator ===


<pre>
<pre>
$ git remote add gerrit ssh://codereview.qt-project.org/qt/<qt5 or the submodule name you have checked out>
git clone git://code.qt.io/qt-creator/qt-creator.git
</pre>
</pre>


If you are behind a SSH-blocking firewall, use the https protocol:
Setup the gerrit remote


<pre>
<pre>
$ git remote add gerrit https://codereview.qt-project.org/p/qt/<qt5 or the submodule name you have checked out>
git remote add gerrit ssh://codereview.qt-project.org/qt-creator/qt-creator
</pre>
</pre>


For Qt 4.8, use
If you are behind a SSH-blocking firewall, use the https protocol:


<pre>
<pre>
$ git remote add gerrit ssh://codereview.qt-project.org/qt/qt
git remote add gerrit https://codereview.qt-project.org/a/qt-creator/qt-creator
</pre>
</pre>


If you are behind a SSH-blocking firewall, use the https protocol:
== Setting up git hooks ==
 
'''NOTE:''' This is only needed if you did NOT use the init-repository script to get the source code, that automatically configures the git hooks for you.


To set up the git hooks, install the hook generating Commit-Id files into your top level project directory, as well as all sub-repositories (e.g. qtbase.git) either through (bash)
<pre>
<pre>
$ git remote add gerrit https://codereview.qt-project.org/p/qt/qt
gitdir=$(git rev-parse --git-dir); scp -P 29418 codereview.qt-project.org:hooks/commit-msg ${gitdir}/hooks/
</pre>
</pre>
or for Powershell, using utilities provided by puTTY:
<pre>
$gitdir=$(git rev-parse --git-dir); pscp -p -P 29418 <user>@codereview.qt-project.org:hooks/commit-msg $gitdir/hooks/
</pre>
or by downloading the file via browser: [http://codereview.qt-project.org/tools/hooks/commit-msg commit-msg] and putting it into the <tt>.git/hooks</tt> directory (make sure it is executable).


=== Cloning repositories ===
It is recommended to install the git_post_commit_hook from the [https://code.qt.io/cgit/qt/qtrepotools.git/ qtrepotools] repository. This gives you the checks of the [[Early Warning System|Sanity Bot]] locally. To do this, save the script
<pre>
#! /bin/sh
exec "<path to git clone>/qtrepotools/git-hooks/git_post_commit_hook" "$@"
</pre>
into each <path to git clone>/.git/hooks/post-commit


You should clone from the [http://code.qt.io/ official mirror] and track changes from there in order to keep the load on Gerrit down.
'''NOTE:''' Starting with git 1.7.8, if <tt><module name>/.git</tt> contains <tt>gitdir: ../.git/modules/<module name></tt>, you need to put the submodule hooks in <tt>.git/modules/<module name>/hooks</tt> instead of <tt><module name>/.git/hooks</tt>.
 
== Setting up gerrit git remote ==
 
In order to easily push your changes to Gerrit, we recommend setting a git remote that points to gerrit.
Follow the instructions in one (or more) of the following subsections, depending on which Qt repositories you want to setup Gerrit for.


==== Cloning Qt5 ====
=== Qt5 gerrit git remote ===


Qt 5 is modularized into several repositories which are aggregated by the qt5 super repo.
If you downloaded the sourcecode of Qt5 (or just one of its modules) using something else than the init-repository script, you will have to manually set up the gerrit git remote.
The canonical way to obtain a Qt 5 clone is cloning the super repo from a mirror, and running the init-repository script in qt5 to set up the gerrit remote(s) pointing to codereview, and to clone the submodules:
You don't have to do this if you cloned the Qt5 sourcecode using the init-repository script as described in [[#Cloning Qt5]]. That handles it for you.


<pre>
<pre>
$ git clone git://code.qt.io/qt/qt5.git
git remote add gerrit ssh://codereview.qt-project.org/qt/<qt5 or the submodule name you have checked out>
$ cd qt5
$ ./init-repository -f --no-webkit
</pre>
</pre>


Note that Qt 5 submodules have been changed from absolute to relative URLs (like "../qtbase.git") in the .gitmodules file.
If you are behind a SSH-blocking firewall, use the https protocol:
If you make a clone of git://gitorious.org/qt/qt5 in gitorious as git://gitorious.org/~<username>/qt/<cloned-repository-name>.git the init-repository script will not work. A URL rewrite rule has to be added to the .gitconfig file to make it work:
 
<pre>
<pre>
[url "git://gitorious.org/qt/"]
git remote add gerrit https://codereview.qt-project.org/a/qt/<qt5 or the submodule name you have checked out>
        insteadOf = git://gitorious.org/~<username>/qt/
</pre>
</pre>


Alternatively, individual Qt5 submodules can be manually cloned as well. Follow '''Using Existing Clones''' above after cloning.
=== QtCreator gerrit git remote ===
 
==== Cloning Qt4 ====


<pre>
<pre>
$ git clone git://code.qt.io/qt/qt.git
git remote add gerrit ssh://codereview.qt-project.org/qt-creator/qt-creator
</pre>
</pre>


Note that Qt4 does not have a <tt>master</tt> branch (since no 4.9 is planned). So, you should push changes to the <tt>4.8</tt> branch.
If you are behind a SSH-blocking firewall, use the https protocol:
 
==== Cloning Qt Creator ====


<pre>
<pre>
$ git clone git://code.qt.io/qt-creator/qt-creator.git
git remote add gerrit https://codereview.qt-project.org/a/qt-creator/qt-creator
</pre>
</pre>


=== Pushing your local changes to gerrit ===
== Pushing your local changes to gerrit ==


See [[Gerrit Introduction]].
See [[Gerrit Introduction]].

Revision as of 19:13, 2 January 2020


All projects under the Qt Open Governance umbrella are hosted on our Gerrit Instance. There is an official mirror and browser of these repositories.

In order to be able to propose changes to those projects, you have to first setup your Gerrit account and get Qt's sourcecode, following the steps below:

  1. Set up a Gerrit account
  2. Tweak your SSH config as instructed here
  3. Use the recommended Git settings, defined here
  4. Get the source code of the projects you want to contribute to

Moreover, if you did not use the init-repository scripts to get the source code, you will have to manually:

  1. Set up the git commit hooks .
  2. Set up a Gerrit git remote.

Once all the steps above have been completed, you're ready to submit your patch to Qt!

See also:

How to get started - Gerrit registration

  1. Create a Qt account, if you don't have one yet.
    • Note: Use an all-lowercase user name. Otherwise, Gerrit will lowercase it for you, and as it is case sensitive, you will have to use mismatched login names.
  2. Log into https://codereview.qt-project.org with your Qt account.
  3. Go to "Settings" -> "Contact Information", set your real name and register your email address, if it hasn't been automatically registered.
    • You will receive a confirmation email; click on the link inside to finalize your registration.
      • If you use Outlook, manually copy the link including any trailing equal signs into the browser.
    • Note: The email address you use to contribute to the Qt Project will be publicly visible in the Git history. Use an alias + a custom e-mail address if you want to stay anonymous (this is discouraged)
  4. Review and agree to the Qt Project's contribution license agreement (CLA) in Gerrit. You need to do this only once, unless the license changes.
    • If your company has a corporate contribution agreement, ask the admin of your company's Gerrit user group to add your account to this group.
    • More details about the CLA can be found here.
  5. Go to "Settings"-> "SSH Public Keys" and upload your public SSH Key
  6. If you are behind a firewall that blocks SSH access:
    1. Go to "Settings" -> "HTTP Password"
    2. Click "Generate Password"
    3. Add the following line to your ~/.netrc (Windows: ​%USERPROFILE%\_netrc):
      machine codereview.qt-project.org login <Gerrit username> password <Generated password>

Local Setup

Proper configuration of SSH for your Gerrit account is necessary for the URLs in the next steps.

Additionally, adding an SSH public key to your gerrit user account can be useful for custom applications that watch Gerrit for certain events and do things such as post automated comments, pull and build commits automatically, etc...

The instructions below are applicable to Linux (Terminal), Mac (Terminal), and Windows (Powershell).

Note: SSH keys are intended to be unique to each machine. New keys must be created for each additional machine logging in to Gerrit with SSH.

Note: On windows, the ~/ shorthand used below can be equated with C:\Users\%USERNAME%\. Make replacements in the example as necessary.

  1. Edit "~/.ssh/config" with host information for gerrit. See sample below. Do not copy comments marked by #. They may not be ignored by your OS.
    Host codereview.qt-project.org
        Hostname codereview.qt-project.org
        Port 29418
        # this is your Gerrit username, not email, and not your PC's username. You can view this from Settings in gerrit when logged in.
        User yourgerritusername
        PreferredAuthentications publickey
        IdentityFile ~/.ssh/id_rsa
    
  2. Generate your key pairs with the ssh-keygen tool following the format below. Use Powershell in windows, Terminal in linux, or Console in Mac.
    ssh-keygen -t rsa -b 4096 -C youremail@email.com -f ~/.ssh/id_rsa
  3. Log into codereview.qt-project.org and navigate to Settings → SSH Public Keys
  4. From the ~/.ssh directory, open the newly created id_rsa.pub file with a text editor.
  5. Copy the entire contents and paste into a new key entry in you Gerrit's SSH Public Keys page.
  6. Save the new entry in your Gerrit settings.
  7. You can test to verify the connection works by running: ssh codereview.qt-project.org gerrit stream-events
  8. If the connection is functional, every Gerrit event should be displayed in raw format to your console.

Configuring Git

We are developing in a heterogeneous environment with both Unix and Windows machines. Therefore it is imperative to have all files in the repository in the canonical LF-only format. Therefore, Windows users must run

git config --global core.autocrlf true

to automatically get CRLF line endings which are suitable for the native tools, and Unix users should use

git config --global core.autocrlf input

(this is a safety measure for the case where files with CRLF line endings get into the file system- this can happen when archives are unpacked, attachments saved, etc.).

To be able to create commits which can be pushed to the server, you need to set up your committer information correctly:

git config --global user.name "Your Name"
git config --global user.email "me@example.com"

Please do not use nicknames or pseudonyms instead of the real name unless you have really good reasons. Gerrit will not accept your commits unless the committer information matches the email address(es) you registered.

To facilitate following the style guide for commit messages, it is recommended to install the Qt commit message template:

git config --global commit.template <path to qt5.git or qt.git>/.commit-template

A common mistake is forgetting to add new files to a commit. Therefore it is recommended to set up git to always show them in git stat and git commit, even if this is somewhat slower (especially on Windows):

git config --global status.showuntrackedfiles all

Pre-2.0 git has a somewhat stupid default that git push will push all branches to the upstream repository, which is almost never what you want. To fix this, use:

git config --global push.default tracking

This is not relevant for mainline branches under Gerrit control, as all pushing happens with refs anyway, but it may be important for your private clones.

Sometimes it is necessary to resolve the same conflicts multiple times. Git has the ability to record and replay conflict resolutions automatically, but - surprise surprise - it is not enabled by default. To fix it, run:

git config --global rerere.enabled true
git config --global rerere.autoupdate true # this saves you the git add, but you should verify the result with git diff --staged

git pull will show a nice diffstat, so you get an overview of the changes from upstream. git pull --rebase does not do that by default. But you want it:

git config --global rebase.stat true

To get nicely colored patches (from git diff, git log -p, git show, etc.), use this:

git config --global color.ui auto
git config --global core.pager "less -FRSX"

Git supports aliases which you can use to save yourself some typing. For example, these (any similarity with subversion command aliases is purely accidental ;)):

git config --global alias.di diff
git config --global alias.ci commit
git config --global alias.co checkout
git config --global alias.ann blame
git config --global alias.st status

Getting the source code

Cloning Qt5

You should clone from the official mirror and track changes from there in order to keep the load on Gerrit down.

This guide will show you how to get and build the source code.

After getting the source code, if you did not use the init-repository script to clone the source code as described in the guide, or you want to manually clone only a submodule, make sure you also manually set up the git commit hooks and set up a git remote that point to Qt's gerrit instance.

Cloning Qt Creator

git clone git://code.qt.io/qt-creator/qt-creator.git

Setup the gerrit remote

git remote add gerrit ssh://codereview.qt-project.org/qt-creator/qt-creator

If you are behind a SSH-blocking firewall, use the https protocol:

git remote add gerrit https://codereview.qt-project.org/a/qt-creator/qt-creator

Setting up git hooks

NOTE: This is only needed if you did NOT use the init-repository script to get the source code, that automatically configures the git hooks for you.

To set up the git hooks, install the hook generating Commit-Id files into your top level project directory, as well as all sub-repositories (e.g. qtbase.git) either through (bash)

gitdir=$(git rev-parse --git-dir); scp -P 29418 codereview.qt-project.org:hooks/commit-msg ${gitdir}/hooks/

or for Powershell, using utilities provided by puTTY:

$gitdir=$(git rev-parse --git-dir); pscp -p -P 29418 <user>@codereview.qt-project.org:hooks/commit-msg $gitdir/hooks/

or by downloading the file via browser: commit-msg and putting it into the .git/hooks directory (make sure it is executable).

It is recommended to install the git_post_commit_hook from the qtrepotools repository. This gives you the checks of the Sanity Bot locally. To do this, save the script

#! /bin/sh
exec "<path to git clone>/qtrepotools/git-hooks/git_post_commit_hook" "$@"

into each <path to git clone>/.git/hooks/post-commit

NOTE: Starting with git 1.7.8, if <module name>/.git contains gitdir: ../.git/modules/<module name>, you need to put the submodule hooks in .git/modules/<module name>/hooks instead of <module name>/.git/hooks.

Setting up gerrit git remote

In order to easily push your changes to Gerrit, we recommend setting a git remote that points to gerrit. Follow the instructions in one (or more) of the following subsections, depending on which Qt repositories you want to setup Gerrit for.

Qt5 gerrit git remote

If you downloaded the sourcecode of Qt5 (or just one of its modules) using something else than the init-repository script, you will have to manually set up the gerrit git remote. You don't have to do this if you cloned the Qt5 sourcecode using the init-repository script as described in #Cloning Qt5. That handles it for you.

git remote add gerrit ssh://codereview.qt-project.org/qt/<qt5 or the submodule name you have checked out>

If you are behind a SSH-blocking firewall, use the https protocol:

git remote add gerrit https://codereview.qt-project.org/a/qt/<qt5 or the submodule name you have checked out>

QtCreator gerrit git remote

git remote add gerrit ssh://codereview.qt-project.org/qt-creator/qt-creator

If you are behind a SSH-blocking firewall, use the https protocol:

git remote add gerrit https://codereview.qt-project.org/a/qt-creator/qt-creator

Pushing your local changes to gerrit

See Gerrit Introduction.