snippetjavascriptTip
View all Git branches
Viewed 0 times
gitbranchesviewall
Problem
To view a list of all branches in a Git repository, you can use the
You can use
Similarly, you can use
git branch command. You may want to do so to see what work is in progress, what branches are available for you to switch to, or to get an overview of the repository's structure.You can use
git branch to display a list of all local branches. As usual, you can use the arrow keys to navigate the list and press <kbd>Q</kbd> to exit.Similarly, you can use
git branch -r to display a list of all remote branches. You can use the same navigation keys and exit key as before.Solution
# Syntax: git branch
git branch
# master
# patch-1
# patch-2Similarly, you can use
git branch -r to display a list of all remote branches. You can use the same navigation keys and exit key as before.Code Snippets
# Syntax: git branch
git branch
# master
# patch-1
# patch-2# Syntax: git branch -r
git branch -r
# origin/master
# origin/patch-1
# origin/patch-2Context
From 30-seconds-of-code: view-all-branches
Revisions (0)
No revisions yet.