Introduction
🧑💻 New to Git or LabEx? We recommend starting with the Quick Start with Git course.
In Git, branches are used to develop features or isolate changes made to the codebase. Local branches are the branches that exist only on your local machine. In this challenge, you will learn how to view a list of all local branches in a Git repository.
View Local Branches
You have been working on a Git repository named https://github.com/labex-labs/git-playground. You want to view a list of all local branches in the repository.
- Navigate to the cloned repository using the following command:
cd git-playground - Use the following command to view a list of all local branches:
You will see a list of all local branches in the repository. Use the arrow keys to navigate through the list and press Q to exit.git branch
This is the final result:

Summary
In this challenge, you learned how to view a list of all local branches in a Git repository. Using the git branch command, you can easily view all the branches that exist on your local machine. This can be useful when you need to switch between branches or merge changes from one branch to another.