Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何获取特定 git commit SHA 上的 git 标签?
使用--contains参数。
示例:要从 shell 中查看 SHA abcd1234上有哪些标签:
git tag --contains abcd1234
它返回标签的名称
v1.1
如果该特定提交上有多个标签,您将用换行符将它们分开:
v1.1 LATEST_STABLE MY-TAG
要通过 bash 脚本在环境变量中设置它:
export GIT_TAG=`git tag --contains $MY_SHA`