In a script, I would like to determine if a tag or a branch was checked out.
For now, I have:
git describe --tags It will show the tag name, but if we are on a branch, it will raise an error (with return status != 0):
fatal: No names found, cannot describe anything. Can I rely on this behavior or is there a better/more official way to do so?
Are there some cases that are not caught by this method that I should know?
git describe --tagsdoesn't throw any error. It just shows the first reachable tag from where you aregit describe --tagsis not good for this, see my own answer ^^