zoukankan      html  css  js  c++  java
  • Git 标签使用详解

    列出标签

    # 默认按字母排序显示
    $ git tag
    
    # 模糊匹配查找标签
    $ git tag -l "v1.8.5*"
    

    创建标签

    # 创建附注标签
    $ git tag -a v1.4 -m "my version 1.4"
    
    $ git show v1.4
    tag v1.4
    Tagger: Ben Straub <ben@straub.cc>
    Date:   Sat May 3 20:19:12 2014 -0700
    
    my version 1.4
    
    commit ca82a6dff817ec66f44342007202690a93763949
    Author: Scott Chacon <schacon@gee-mail.com>
    Date:   Mon Mar 17 21:52:11 2008 -0700
    
        changed the version number
    
    # 创建简单标签
    $ git tag v1.4-lw
    
    $ git show v1.4-lw
    commit ca82a6dff817ec66f44342007202690a93763949
    Author: Scott Chacon <schacon@gee-mail.com>
    Date:   Mon Mar 17 21:52:11 2008 -0700
    
        changed the version number
    
    # 给某个提交创建标签
    $ git tag -a v1.2 9fceb02
    

    推送标签

    默认情况下,git push 命令不会传送标签到远程仓库服务器上。 在创建完标签后必须显式地推送标签到远程仓库上。

    # 推送单个标签
    $ git push origin v1.4-lw
    
    # 推送所有标签
    $ git push origin --tags
    

    删除标签

    # 删除本地标签
    $ git tag -d v1.4-lw
    
    # 删除远程标签方式一
    $ git push origin :refs/tags/v1.4-lw
    
    # 删除远程标签方式二
    $ git push origin --delete <tagname>
    

    检出标签

    注意不要在检出标签后做修改和提交,会出现不必要的麻烦。正确的做法应该是创建一个新的分支,在新的分支上做修改和提交。

    $ git checkout v1.4
    

    参考:https://git-scm.com/book/zh/v2/Git-%E5%9F%BA%E7%A1%80-%E6%89%93%E6%A0%87%E7%AD%BE

  • 相关阅读:
    [uoj173]鏖战表达式
    [cf1168E]Xor Permutations
    [cf578F]Mirror Box
    [cf1261F]Xor-Set
    [loj2506]tree
    [atARC068F]Solitaire
    [atARC066F]Contest with Drinks Hard
    [cf1270I]Xor on Figures
    [cf516D]Drazil and Morning Exercise
    无题
  • 原文地址:https://www.cnblogs.com/danhuang/p/12922635.html
Copyright © 2011-2022 走看看