Add SSH Key to use with Git

Gerrit – Add SSH Key to use with Git ”; Previous Next You can add SSH key to Git using the following commands − Step 1 − Open Git Bash and get the ssh-agent using the following command. $ eval ”ssh-agent” Step 2 − Next, add the SSH key to the ssh-agent using the following command $ ssh-add ~/.ssh/id_rsa Step 3 − Now, run the ssh using the following command, which matches the SSH fingerprint used when logging for the first time. $ ssh -p 29418 <user_name>@gerrit.wikimedia.org In the above screenshot, you can see that xyz123 is a instance shell account name, which is used while creating Gerrit account and Abc123 is a user name of your Gerrit account. Print Page Previous Next Advertisements ”;

Gerrit – Overview

Gerrit – Overview ”; Previous Next Gerrit is a web based code review tool which is integrated with Git and built on top of Git version control system (helps developers to work together and maintain the history of their work). It allows to merge changes to Git repository when you are done with the code reviews. Gerrit was developed by Shawn Pearce at Google which is written in Java, Servlet, GWT(Google Web Toolkit). The stable release of Gerrit is 2.12.2 and published on March 11, 2016 licensed under Apache License v2. Why Use Gerrit? Following are certain reasons, why you should use Gerrit. You can easily find the error in the source code using Gerrit. You can work with Gerrit, if you have regular Git client; no need to install any Gerrit client. Gerrit can be used as an intermediate between developers and git repositories. Features of Gerrit Gerrit is a free and an open source Git version control system. The user interface of Gerrit is formed on Google Web Toolkit. It is a lightweight framework for reviewing every commit. Gerrit acts as a repository, which allows pushing the code and creates the review for your commit. Advantages of Gerrit Gerrit provides access control for Git repositories and web frontend for code review. You can push the code without using additional command line tools. Gerrit can allow or decline the permission on the repository level and down to the branch level. Gerrit is supported by Eclipse. Disadvantages of Gerrit Reviewing, verifying and resubmitting the code commits slows down the time to market. Gerrit can work only with Git. Gerrit is slow and it”s not possible to change the sort order in which changes are listed. You need administrator rights to add repository on Gerrit. Print Page Previous Next Advertisements ”;

Set Your Username & Email

Gerrit – Set Your Username & Email ”; Previous Next You can track each commit by setting name and email variables. The name variable specifies the name, while the email variable identifies the email address associated with Git commits. You can set these using the following commands − git config –global user.email “[email protected]” git config –global user.name “your_name” When you run the above commands, you will get the user name and email address as shown in the following image. Print Page Previous Next Advertisements ”;

Installing Git-Review

Gerrit – Installing Git-Review ”; Previous Next You can work with Gerrit by installing git-review on different platforms as discussed in this chapter. Windows In Windows, you can install the git-review as listed in the following steps. Step 1 − First install Python for installing git-review. Step 2 − Keep the Python installation in the default directory (like C:Python27) instead of installing in any other directory. Step 3 − Next, set the environment variables for Python scripts directory using the path as C:Python27;C:Python27Scripts; git_review_install Step 4 − With version 2.7, Python will install pip automatically. For older version of Python 2.7, you can install pip as described in this link. Step 5 − Run open Git Bash and install the git-review using the following command. $ pip install git-review Linux In Linux, you can install git-review as described in the following steps − Step 1 Users of Linux platform do not have root access on shared host. Hence, without root access, you can install git-review locally in user directory using the following commands − virtualenv –python=/usr/bin/python2.6 virtualenv virtualenv/bin/pip install git-review==1.21 Step 2 − You can extend the path to the local binaries using two ways − PATH=$PATH:~/virtualenv/bin/ PATH=~/virtualenv/bin/:$PATH Step 3 − Now, use the following command to set up the work with Gerrit. git review -s or ~/virtualenv/bin/git-review -s Step 4 − With root access, git-review can be installed using the following command. sudo apt-get install git-review Step 5 − If there is no apt-get after installing Python, then use the following commands. $ sudo easy_install pip $ sudo pip install git-review==1.21 Step 6 − Run the following command to work with Gerrit. git review -s Mac OS X In Mac, you can install the git-review using the following steps. Step 1 − Install the Homebrew from this link. Step 2 − Next, install the git-review using the following command. brew install git-review Print Page Previous Next Advertisements ”;

Setting up Git-Review

Gerrit – Setting Up Git-Review ”; Previous Next Git-review can be used to send git branches to Gerrit for reviewing. You can set up gitreview using the following command in the project directory. $ git review -s Git-review can be used as the command line tool for configuring Git clone, submitting the branches to Gerrit, fetching the existing files, etc. Git-review looks for the remote named gerrit for working with Gerrit by default. If git-review finds the Gerrit remote, then it will submit the branch to HEAD:refs/for/master at the remote location and if there is no Gerrit remote access, then git-review looks for the .gitreview file at the root of the repository along with the gerrit remote information. Git-review processes the following internally − It will check whether the remote repository works or not for submitting the branches. If there is no Gerrit remote access, then it will ask for the username and try to access the repository again. It will create a remote access called gerrit that points to Gerrit. It will install the commit-msg hook. Print Page Previous Next Advertisements ”;