006.progit笔记---git打标签

01、查看已有标签

  $ git tag  (按照字母顺序,列出所有标签)

  $ git tag -l 'v1.0.*'  (列出所有v1.0.*的标签)

02、打轻量标签(lightweight)

  $ git tag v1.0.0

03、打附注标签(annotated)

  $ git tag -a v1.0.0 -m 'my version v1.0.0'

04、查看标签详情

  $ git show v1.0.0

05、给历史提交打标签

  $ git log --pretty=oneline  (查看提交历史)

  $ git tag -a v1.2  9fceb02   (给历史提交打标签,加上校验和或开头部分校验和)

06、将标签推到远程服务器

  $ git push <remote-name> <tag>

  $ git push my v1.0.0  (将v1.0.0标签推到my远程仓库)

  $ git push <remote-name> --tags  (将所有不在远程仓库的标签推到远程仓库)

07、删除标签

  $ git tag -d v1.0.0  (删除本地仓库的v1.0.0标签)

  $ git push <remote-name> :refs/tags/<tagname>  (更新到远程仓库)

08、迁出标签代码

  $ git checkout v1.0.1  (此时处于分离头指针(detacthed HEAD)状态。提交时,标签不会移动,导致新提交不属于任何分支)

  $ git checkout -b newBranch v1.0.0  (迁出代码,并创建新分支,基于新分支修改提交)

猜你喜欢

转载自www.cnblogs.com/geniushuangxiao/p/12655653.html