Book Image

Git Best Practices Guide

By : PIDOUX Eric
Book Image

Git Best Practices Guide

By: PIDOUX Eric

Overview of this book

Table of Contents (12 chapters)

Working with branches


Git allows you to create branches, that is, named pointers to commits. You can work on different branches independently from each other. The default branch is most often called master.

A branch pointer in Git is 41 bytes large: 40 bytes of characters and an additional new line character. So, it explains why Git is very fast and cheap in terms of resource consumption.

If you decide to work on a branch, you have to checkout the branch. This means that Git restructures the working tree with the content of the commit to which the branch points and moves the HEAD pointer to the new branch.

The first command to know is:

Jim@local:~/webproject$ git branch

This command will display all available local branches for the repository. Inside the given list, the current working branch has the prefix *.

If you want to see all branches, including the remote branches, you will have to execute the following command:

Jim@local:~/webproject$ git branch -a

Creating a branch

You can create a...