Listing Branch Names

The git branch command lists branch names found in the repository:

$ git branch
  bug/pr-1
  dev
* master

In this example, three topic branches are shown. The branch currently checked out into your working tree is identified by the asterisk. This example also shows two other branches, bug/pr-1 and dev.

Without additional parameters, only topic branches in the repository are listed. As you’ll see in Chapter 11, there may be additional remote tracking branches in your repository. You can list those with the -r option. You can list both topic and remote branches with -a.

Get Version Control with Git now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.