Linux command
git-describe 命令
文本
复制后可按需替换文件名、目录或参数。
常用示例
Describe current commit
git describe
Describe with all tags
git describe --tags
Describe specific commit
git describe [commit]
Long format always
git describe --long
Match tag pattern
git describe --match "v*"
说明
git describe gives a human-readable name to a commit based on available tags. It finds the most recent tag reachable from the commit and describes the distance from it. Output format is tag-distance-gSHA, like "v1.0.2-14-g2414721" meaning 14 commits after v1.0.2. If the commit is directly on a tag, just the tag name is returned. This is commonly used for generating version strings in build systems.
参数
- --tags
- Use any tag, not just annotated.
- --long
- Always output long format.
- --match _PATTERN_
- Only consider matching tags.
- --abbrev _N_
- Abbreviation length.
- --always
- Show commit abbrev if no tag found.
- --help
- Display help information.
FAQ
What is the git-describe command used for?
git describe gives a human-readable name to a commit based on available tags. It finds the most recent tag reachable from the commit and describes the distance from it. Output format is tag-distance-gSHA, like "v1.0.2-14-g2414721" meaning 14 commits after v1.0.2. If the commit is directly on a tag, just the tag name is returned. This is commonly used for generating version strings in build systems.
How do I run a basic git-describe example?
Run `git describe` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does --tags do in git-describe?
Use any tag, not just annotated.