Get Name of Current Branch This has not been pretty in the past, but from Git 2.22 you can simply do: $ git branch --show-current main Resources and References StackOverflow: "How to get the current branch name in Git?"