Skip to content

Latest commit

 

History

History
20 lines (15 loc) · 529 Bytes

get-the-name-of-the-current-branch.md

File metadata and controls

20 lines (15 loc) · 529 Bytes

Get The Name Of The Current Branch

There are a couple ways of doing this. If you are on Git 2.22+, then the git-branch porcelain command now supports a flag for this.

$ git branch --show-current
main

If you are on an older version of Git or looking for a plumbing command that is more appropriate for scripting, then git-rev-parse is what you're looking for.

$ git rev-parse --abbrev-ref HEAD
main

source