How to programmatically determine whether the Git checkout is a tag and if so, what is the tag name

后端 未结 6 579
北恋
北恋 2020-12-23 13:14

In a Unix or GNU scripting environment (e.g. a Linux distro, Cygwin, OSX), what is the best way to determine whether the current checkout is a Git tag. If it is a tag, how c

6条回答
  •  别那么骄傲
    2020-12-23 14:02

    The best way to do this is to use the git describe command:

    git-describe - Show the most recent tag that is reachable from a commit

    The command finds the most recent tag that is reachable from a commit. If the tag points to the commit, then only the tag is shown. Otherwise, it suffixes the tag name with the number of additional commits on top of the tagged object and the abbreviated object name of the most recent commit.

提交回复
热议问题