How do you list all the branches in a Git repository?

How do you list all the branches in a Git repository?

a) git list
b) git branches
c) git show-branches
d) git branch

Answer:

d) git branch

Explanation:

The git branch command lists all the branches in your repository. It shows the currently checked-out branch with an asterisk (*) next to it.

For example, running git branch displays a list of all local branches. To view both local and remote branches, you can use git branch -a.

Listing branches helps you keep track of different streams of work in your repository and easily switch between them when necessary.

Reference:

Top 100 Git and GitHub MCQ Questions and Answers

Scroll to Top