In Git, a branch is a pointer to a specific commit. It is a way to keep developing and coding a new feature or modification to the software without affecting the main part of the project. Branches are lightweight and can be created, listed, renamed, and deleted using the git branch
command. The default branch name in Git is master
. As you start making commits, youre given a master
branch that points to the last commit you made. Every time you commit, the master
branch pointer moves forward automatically. Branches serve as an abstraction for the edit/stage/commit process, and you can think of them as a way to request a brand new working directory, staging area, and project history. When you want to add a new feature or fix a bug, you spawn a new branch to encapsulate your changes. As you commit changes, the branch pointer moves forward, keeping track of the latest commit. The branch graph diverges only when a commit diverges from a common ancestor.