Get the current branch name

Git, Branch · Apr 13, 2021

Prints the current branch name.

  • Use git rev-parse --abbrev-ref HEAD to print the name of the current branch.
git rev-parse --abbrev-ref HEAD
git checkout patch-1
git rev-parse --abbrev-ref HEAD # Prints `patch-1`

More like this