Skip to main content
  1. Learn
  2. Software Development
  3. Guides
  4. Git tutorial
  5. Git collaboration
  6. Branches
  7. Creating branches
GuidesSoftware DevelopmentBacklog
Git

Project and code management together.

Creating branches

Creating a branch in Git means establishing a separate line of development that diverges from the main codebase. When you create a branch, Git essentially creates a pointer to a specific commit, typically the commit you were on when you created the branch.

Creating a new branch does not change the repository; it simply points out the commit.

For example, if we create a branch called issue1 using the git branch command, the repository will remain the same, but we have added a new pointer to the current commit.

The illustration below shows what happens when we create this branch.

Diagram of creating branches.

Here’s a breakdown of what happens when you create a branch:

  1. Pointer creation: Git creates a new pointer (or reference) to a specific commit in the repository. This commit is often referred to as the "head" of the branch.
  2. Independent development: The new branch initially contains the exact same code and commit history as the branch it was created from. This allows you to start making changes and commits independently from other branches.
  3. Commit history: As you make new commits on the new branch, Git updates the branch pointer to track the latest commit. Each commit on the branch builds upon the previous one, forming a chronological history of changes specific to that branch.
  4. Branch naming: Branches are typically named to reflect the feature being worked on, the issue being addressed, or any other relevant identifier. Naming conventions often help in identifying the purpose of each branch.

Subscribe to our newsletter

Learn with Nulab to bring your best ideas to life