0
0
Gitdevops~10 mins

Listing branches in Git - Mini Project: Build & Apply

Choose your learning style9 modes available
Listing branches
📖 Scenario: You are working on a project using Git for version control. You want to see all the branches available in your repository to decide which one to work on next.
🎯 Goal: Learn how to list all branches in a Git repository using commands.
📋 What You'll Learn
Use the git branch command to list branches
Understand the difference between local and remote branches
Use the git branch -a command to list all branches including remote
💡 Why This Matters
🌍 Real World
Developers often need to see all branches in a project to manage features, fixes, and releases effectively.
💼 Career
Knowing how to list branches is a fundamental Git skill required for collaboration and version control in software development jobs.
Progress0 / 4 steps
1
List local branches
Type the command git branch to list all local branches in your Git repository.
Git
Need a hint?

This command shows all branches that exist locally in your repository.

2
Add option to list all branches
Add the option -a to the git branch command to list all branches, including remote branches. Type git branch -a.
Git
Need a hint?

The -a option shows both local and remote branches.

3
List remote branches only
Type the command git branch -r to list only the remote branches in your Git repository.
Git
Need a hint?

The -r option lists only remote branches.

4
Display the current branch
Type the command git branch and observe the output. Notice the branch with an asterisk * which shows the current active branch.
Git
Need a hint?

The current branch is marked with an asterisk * in the list.