What Is a Branch?
What
A Branch in Git allows you to isolate a line of development. It enables you to work on new features, bug fixes, or experimental changes without affecting the stable “production” code (typically stored on the default branch).
How
You can inspect the existing branches in your local repository at any time using the git branch command:
# List all local branches
git branch
The branch you are currently working on will be highlighted and marked with an asterisk (*) in the command’s output.
Why
Under the hood, a branch is not a full copy of all your project’s folders and files on your hard drive. Instead, a branch is simply a lightweight, mobile pointer that references a specific commit hash. The commit that a branch pointer currently references is called the tip of the branch. Because Git branches are just tiny text files containing 40-character commit hashes, creating and deleting branches is instantaneous and uses practically zero disk space.
Summary
Git branches are highly lightweight pointers that reference specific commits, allowing you to isolate and develop multiple independent lines of features simultaneously.