Book Image

Learning Gerrit Code Review

By : Luca Milanesio
Book Image

Learning Gerrit Code Review

By: Luca Milanesio

Overview of this book

<p>Developing software is now more than ever before a globally distributed activity: agile methodologies that worked well enough with co-located teams now need to be empowered with additional tools such as Gerrit code review to allow the developers to share, discuss, and cooperate in a more social way, even with GitHub.</p> <p>Learning Gerrit Code Review is a practical guide that provides you with step-by-step instructions for the installation, configuration, and use of Gerrit code review. Using this book speeds up your adoption of Gerrit through the use of a unique, consolidated set of recipes ready to be used for LDAP authentication and to integrate Gerrit with Jenkins and GitHub.</p> <p>Learning Gerrit Code Review looks at the workflow benefits of code review in an agile development team, breaks it down into simple steps, and puts it into action without any hassle. It will guide you through the installation steps of Gerrit by showing you the most typical setup and configuration schemes used in private networks.</p> <p>You will also learn how to effectively use Gerrit with GitHub in order to provide the ability to add more consistent code review functionality to the social collaboration tools provided by the GitHub platform. Using the two tools together, you will be able to reuse your existing accounts and integrate your GitHub community into the development lifecycle while keeping in touch with external contributors.</p>
Table of Contents (17 chapters)
Learning Gerrit Code Review
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Working with Git branches


Every commit is linked to its predecessor through its parent commit ID. The named head points to a series of linked commits in a path is called a branch. The default branch in Git is called the master. When a branch is labeled, the commits can be referenced using their branch name instead of the commit ID. The command git branch branch-name branch-start assigns a new branch label to an existing starting point (commit ID or branch name). In the following example, we will create the branch oldmaster that points to our first commit:

$ git branch oldmaster 4febfb3

The branch label is automatically updated with the latest commit added to it.

The command git branch without arguments displays the list of named branches, the current one prefixed by *:

$ git branch
* master
  oldmaster

The command git checkout branch (commit ID or branch name) extracts from the Git repository all of the files associated to the commit pointed to branch:

$ git checkout oldmaster
Switched to branch 'oldmaster'
$ cat hello.txt
hello world

$ git checkout master
Switched to branch 'master'
$ cat hello.txt
hello git world

It can be very useful to display the current branch point on the working directory. When using bash, it is possible to set up a custom prompt which includes the current branch as a prefix under brackets:

$ source \
  /usr/local/git/contrib/completion/git-completion.bash
$ export PS1='$(__git_ps1 " (%s)") \$ '
(master) $ git checkout oldmaster
(oldmaster) $

Tip

Git branches can be created from any commit in the history; this creates an arbitrary set of branches that connects all of the Git commits, which is called a Git graph. This can often be very complex, so it can be graphically displayed using the gitk GUI utility included in the Git distribution.