简体   繁体   中英

How to get latest tag name not using `git fetch --tags`

There has been an answer said how to get a latest tag, https://stackoverflow.com/a/7979255/7909869 . But the premise is we must use git fetch --tags first after I use git clone REPO --depth=1 . My REPO has many tags that means git fetch --tags will take a lot of time to download tags, and my request here is just to get the latest tag name not the whole code.

You could take a look at git describe :

  • git describe --abbrev=0 it should return closest annotated tag

  • or to get the latest annotated tag which targets only the current commit in the current branch, use

    git describe --exact-match --abbrev=0

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM