Hello, fellow devs!
Have you ever been in a situation where you have been switching to multiple branches and need to remember the name of one branch you needed?
Don't worry, it's a daily struggle!
To overcome that struggle I have added a quick guide below along with a demo on how to list all branches in remote and local repositories and a few bonus tips related to branch management.
Learn to efficiently display all branches in a Git repository using the command-line interface (CLI).
Steps to follow:
1. Open the terminal in VS Code by using the shortcut 'CTRL +'.
2. To display all the local branches, run the below command:
git branch
3. To display all the remote branches run the below command:
git branch -r
4. To display both local and remote branches, run the below command:
git branch -a
That’s it.
With these simple steps, you can effortlessly keep track of all your local and remote branches in one go.
Now you can easily list all branches in your Git repository using simple commands.
This will help you quickly navigate between local and remote branches without confusion.
With this, you can manage branches efficiently clean them up as needed, and maintain a smoother workflow.
Below are the commands that provide detailed information about the branch's commit messages and commit ID
- git branch -v (for local branches)
- git branch -rv (for remote branches)
- git branch -av (for both local and remote branches)
The -v option stands for "verbose" and provides more detailed information about each branch.
To identify which local branch you're currently on, run the below command git branch Look for the branch name with an asterisk (*) next to it. This indicates the active local branch.
git branch -r lists only remote branches, and git branch -a lists both local and remote branches.
Still have questions?
Send an email to archana@leadwalnut.com, OR
Book a FREE consultation with an expert developer here.