Book Image

Git Version Control Cookbook

By : Aske Olsson, Rasmus Voss
Book Image

Git Version Control Cookbook

By: Aske Olsson, Rasmus Voss

Overview of this book

Table of Contents (19 chapters)
Git Version Control Cookbook
About the Authors
About the Reviewers

Managing your local branches

Suppose you are just having your local Git repository, and you have no intentions at the moment to share the code with others; however, you can easily share this knowledge while working with a repository with one or more remotes. Local branches with no remotes work exactly in this fashion. As you can see in the examples, we are cloning a repository, thus we have a remote.

Let's start by creating a few local branches.

Getting ready

Use the following command to clone the jgit repository to match:

$ git clone
$ cd jgit

How to do it…

Perform the following steps to manage your local branches:

  1. Whenever you start working on a bug fix or a new feature in your project, you should create a branch. You can do so using the following code:

    $ git branch newBugFix
    $ git branch
    * master
  2. The newBugFix branch points to the current HEAD I was on at the time of the creation. You can see the HEAD with git log -1:

    $ git log -1 newBugFix ...