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
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Working with branches


One of the great powers of Git is the cheapness of creating branches. Branches are a way to create new code away from the central code path. You can see a branch as a tree, and you have a tree branch that sticks out of the tree.

So, when you want to test a new feature, just create a new branch. If you like the feature, you can merge it back. If you don't like the feature, you can remove the branch and no harm is done to the main branch.

In this recipe, we will take a look at how to create branches in Git, where you can find the branches in GitLab, and even how you can create a branch right in the GitLab interface.

Getting ready

You need to have a repository with at least one file, and commit changes in it. In the examples, I'll be using the super-git project created at the start of this chapter.

How to do it…

In the following steps, we will use branches to push our code:

  1. Go to your Git project in the terminal.

  2. Tell Git to create a new branch and decide what name it should have...