代码改变世界

为Git branch 打Tag

2020-09-03 17:19  divl  阅读(256)  评论(0编辑  收藏  举报

tag is a pointer to a commit, and commits exist independently of branches.

 

Branches come into play only indirectly:

  • At the time of creating a tag, by implying the commit that the tag will point to:
    • Not specifying a target for a tag defaults to the current branch's most recent commit (a.k.a. HEAD); e.g.:
      • git tag v0.1.0 # tags HEAD of *current* branch
    • Specifying a branch name as the tag target defaults to that branch's most recent commit; e.g.:
      • git tag v0.1.0 develop # tags HEAD of 'develop' branch
    • (As others have noted, you can also specify a commit ID explicitly as the tag's target.)