In a Unix or GNU scripting environment (e.g. a Linux distro, Cygwin, OSX), what is the best way to determine which Git branch is currently checked out in a working directory?
One use of this technique would be automatically labeling a release (like svnversion
would do with Subversion).
Please also see my related question: How to programmatically determine whether a Git checkout is a tag, and if so what is the tag name?