Previous chapters focused on managing a project's history along a single path. Real-world development, however, often requires working on multiple tasks concurrently. For instance, you might need to develop a new feature while separately fixing a bug in the released version, without the two efforts interfering with each other.
Git facilitates this parallel work through its branching mechanism. Branches act as independent lines of development within your repository. This chapter introduces the fundamental concepts and commands for working with branches. You will learn how to create new branches (git branch
), navigate between them (git switch
or git checkout
), and integrate the work done on different branches back together (git merge
). We will also address how to resolve merge conflicts, which can occur when combining divergent changes. Finally, managing branches, including listing and deleting them, will be covered.
4.1 What Are Branches in Git?
4.2 Creating a New Branch (git branch)
4.3 Switching Between Branches (git checkout or git switch)
4.4 Listing Branches
4.5 Making Commits on a Branch
4.6 Merging Branches (git merge)
4.7 Understanding Fast-Forward Merges
4.8 Handling Merge Conflicts
4.9 Deleting Branches (git branch -d)
4.10 Hands-on Practical: Branching and Merging Workflow
© 2025 ApX Machine Learning