Book Image

Gitlab Cookbook

By : Jeroen van Baarsen
Book Image

Gitlab Cookbook

By: Jeroen van Baarsen

Overview of this book

Table of Contents (16 chapters)
GitLab Cookbook
About the Author
About the Reviewers


GitLab is a popular, open source Git hosting solution implemented by more than 50,000 organizations. Over the last few years, GitLab has evolved with strong community support and growth, handling thousands of users on a single server and several such servers on an active cluster. If you need to set up a Git server, GitLab provides a perfect solution for you!

This book has some carefully chosen recipes to help you decide on the type of GitLab installation that will fit your requirements. You will also explore the benefits of each of these installation types.

Along with covering some of the basic principles of Git, the book covers practical scenarios that will show how you or your organization can effectively manage your proprietary code. You will learn how to manage multiple users, groups, and the permissions GitLab has for them. Updating your GitLab instance, creating backups, and restoring backups are some of the important tasks that are described in detail in order to assist you in maintaining your GitLab server. Moreover, the GitLab API is extensively covered to guide you through the various operations to help you manage your project. Among some of the more complex stuff, you will see how to incorporate the Git workflow and integrate GitLab in your existing LDAP environment. Furthermore, the book takes a peek at the GitLab CI, which is a continuous integration service specially built by people from GitLab for GitLab.

To summarize, this Cookbook will provide you with the knowledge required to work effortlessly toward self-hosting your Git repositories and maintaining them. Whether you are dealing with small or large projects, the recipes conveniently provide you with a thorough learning curve to help you handle the repository with speed and efficiency.

What this book covers

Chapter 1, Introduction and Installation, looks at the different ways in which you can install GitLab. We will also create your first project on your own GitLab server.

Chapter 2, Explaining Git, looks at the basics of Git, how to send your code to your GitLab server, how to get your GitLab project on your computer, and how to squash your commits into one nice commit.

Chapter 3, Managing Users, Groups, and Permissions, looks at how you can add new users and what the different permissions that you can grant your users are. We will also look at the power of GitLab groups.

Chapter 4, Issue Tracker and Wiki, shows how GitLab has a powerful issue tracker and wiki system. In this chapter, we will take a look at how you can get the most out of it.

Chapter 5, Maintaining Your GitLab Instance, shows how you need to maintain a GitLab instance and update backups when running them. We will look it all up!

Chapter 6, Webhooks, External Services, and the API, looks at webhooks and shows how you can test them. We will look at linking your GitLab system to external services such as project management tools, and we will look at the powerful API that GitLab ships with.

Chapter 7, Using LDAP and OmniAuth Providers, looks at how you can use your LDAP infrastructure to manage your GitLab users. We will also look at how to use external authentication methods called OmniAuth providers.

Chapter 8, GitLab CI, talks about GitLab having a powerful Continuous Integration system. In this chapter, we will look at how you can install and link it to your GitLab server.

Appendix, Tips and Tricks, looks at some smaller tasks, tips, and tricks that can help you in your daily GitLab usage.

What you need for this book

In this book, we will use a server to which you can install GitLab, so you need to have a server, VPS, or Virtual Machine with at least the following specifications:

  • Ubuntu 12.03 64-bit or newer

  • A CPU with one or two cores

  • 1 GB RAM or 2 GB

For most of the recipes, you also need a working Internet connection, as you need to download certain packages.

Who this book is for

This book is intended for developers and DevOps that have a GitLab server running and want to be sure that they use it to the fullest. It is also aimed at people who are looking for a great Git platform and want to learn how to set it up successfully. Some system administrating skills on a Unix-based system are preferred but not required.


In this book, you will find several headings that appear frequently (Getting ready, How to do it, How it works, There's more, and See also).

To give clear instructions on how to complete a recipe, we use these sections as follows:

Getting ready

This section tells you what to expect in the recipe, and describes how to set up any software or any preliminary settings required for the recipe.

How to do it…

This section contains the steps required to follow the recipe.

How it works…

This section usually consists of a detailed explanation of what happened in the previous section.

There's more…

This section consists of additional information about the recipe in order to make the reader more knowledgeable about the recipe.

See also

This section provides helpful links to other useful information for the recipe.


In this book, you will find a number of styles of text that distinguish between different kinds of information. Here are some examples of these styles, and an explanation of their meaning.

Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: "You can now log in with the username root and password 5iveL!fe."

A block of code is set as follows:

production: &base
    port: 80 

When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:

      editor = 'vim'

Any command-line input or output is written as follows:

$ sudo gitlab-ctl restart

New terms and important words are shown in bold. Words that you see on the screen, in menus or dialog boxes for example, appear in the text like this: "Postfix will ask you what kind of installation you want; choose the Internet Site option."


Warnings or important notes appear in a box like this.


Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or may have disliked. Reader feedback is important for us to develop titles that you really get the most out of.

To send us general feedback, simply send an e-mail to , and mention the book title via the subject of your message.

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide on

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.


Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you would report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting, selecting your book, clicking on the errata submission form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded on our website, or added to any list of existing errata, under the Errata section of that title. Any existing errata can be viewed by selecting your title from


Piracy of copyright material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works, in any form, on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at with a link to the suspected pirated material.

We appreciate your help in protecting our authors, and our ability to bring you valuable content.


You can contact us at if you are having a problem with any aspect of the book, and we will do our best to address it.