【发布时间】:2010-12-08 06:16:08
【问题描述】:
在 Unix 或 GNU 脚本环境(例如 Linux 发行版、Cygwin、OSX)中,确定当前在工作目录中签出哪个 Git 分支的最佳方法是什么?
这种技术的一种用途是自动标记发布(就像svnversion 对 Subversion 所做的那样)。
另请参阅我的相关问题:How to programmatically determine whether a Git checkout is a tag, and if so what is the tag name?
【问题讨论】:
-
使用 Git 2.22(2019 年第二季度),您将有一个更简单的方法:
git branch --show-current。见my answer here。