获取 git 历史记录中最后一个标签的提交 ID
Get the commit ID of the last tag in git history
我正在进行未标记的提交。但是提交历史中有标签。因此,以下命令为我提供了历史记录中的最新发布标签
git describe --abbrev=0 --tags
上面输出的标签像 1.15.21
很好。
如何获取创建此标记的提交 ID?
您可以使用 git rev-parse
获取对应于 branch/tag
的提交
git rev-parse HEAD
abc123......
因此您可以使用 xargs
管道化 git describe
的输出
git describe --abbrev=0 --tags | xargs git rev-parse
def456.....
我正在进行未标记的提交。但是提交历史中有标签。因此,以下命令为我提供了历史记录中的最新发布标签
git describe --abbrev=0 --tags
上面输出的标签像 1.15.21
很好。
如何获取创建此标记的提交 ID?
您可以使用 git rev-parse
获取对应于 branch/tag
git rev-parse HEAD
abc123......
因此您可以使用 xargs
git describe
的输出
git describe --abbrev=0 --tags | xargs git rev-parse
def456.....