HiveBrain v1.2.0
Get Started
← Back to all entries
snippetjavascriptTip

View all Git branches

Submitted by: @import:30-seconds-of-code··
0
Viewed 0 times
gitbranchesviewall

Problem

To view a list of all branches in a Git repository, you can use the 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-2


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.

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-2

Context

From 30-seconds-of-code: view-all-branches

Revisions (0)

No revisions yet.