• Skip to primary navigation
  • Skip to main content
Sal Ferrarello
  • About Sal Ferrarello
  • Speaking
  • Connect
    Mastodon GitHub Twitter (inactive)
You are here: Home / Dev Tips / Git branch list without asterisk

Git branch list without asterisk

Last updated on October 6, 2020 by Sal Ferrarello

By default git branch will list all of your local branches with an asterisk (*) in front of the current branch.

e.g.

$ git branch
  develop
* feature/my-new-feature
  main

Why Remove the Asterisk

When writing a script to automate some behavior, it can be helpful to not have the asterisk.

How to Remove the Asterisk

Adding --format='%(refname:short) will define the output format (see more information on format).

e.g.

$ git branch --format='%(refname:short)'
develop
feature/my-new-feature
main
Sal Ferrarello
Sal Ferrarello (@salcode)
Sal is a PHP developer with a focus on the WordPress platform. He is a conference speaker with a background including Piano Player, Radio DJ, Magician/Juggler, Beach Photographer, and High School Math Teacher. Sal can be found professionally at WebDevStudios, where he works as a senior backend engineer.

Share this post:

Share on TwitterShare on FacebookShare on LinkedInShare on EmailShare on Reddit
Warning! This is a draft, not a finalized post. See full draft disclosure.

Filed Under: Dev Tips, Draft, Solution Tagged With: Git

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Copyright © 2023 · Bootstrap4 Genesis on Genesis Framework · WordPress · Log in