专业java、php、iOS、C++、网页设计、平面设计、网络营销、游戏开发、前端与移动开发培训机构

git标签(tag)管理

tag 的作用

  • tag 可以对 git 版本库中阶段性的重要的版本做一个标记(比如说 appStore 上线版本);
  • 我们可以通过 tag 快速地定位到某个重要版本;

tag 的使用

  1. 添加 tag: git tag –a V1.0.0 –m “AppStore上线V1.0.0版本包含注册登录功能”
    git tag –a tag名称 –m “tag注释”    #添加新标签
    
  2. 查看已有 tag:

    1. git tag -l: 只能看到 tag 名称,看不到注释
      V1.0.0
      
    2. git tag -n: 能看到 tag 名称和注释
      V1.0.0          AppStoreV1.0.0版本
      V1.0.1          AppStoreV1.0.1版本
      
    3. git show tag名称,如 git show V1.0.0: 可以看到 tag 名称, 谁打的 tag, 打 tag 的时间 和 这个 tag 指向哪个提交

      tag V1.0.0
      Tagger: Manager <Manager@itcast.cn>
      Date:   Tue Jun 14 22:51:54 2016 +0800
      
      AppStoreV1.0.0版本
      
      commit dfed15e8b5e687533839d315af9b397daee3da2d
      Author: Manager <Manager@itcast.cn>
      Date:   Tue Jun 14 22:43:38 2016 +0800
      
  3. 删除一个标签: git tag -d 标签名 如: git tag -d V1.0.0
  4. 将标签推送到服务器: git push 不会将 tag 提交到服务器
    1. 推送单个标签 git push origin 标签名称 如: git push origin V1.0.1
    2. 推送所有标签 git push origin --tags

tag 的相关操作包括: 添加删除查看 、提交到服务器等

git tag –a V1.0.0 –m "name"    #添加新标签 
git tag     #查看所有tag
git tag -n  #查看所有 tag,带注释
git show V1.0.0    #查看某个标签及其对应版本的详细信息
git tag -d V1.0.0  #删除一个版本
git push origin V1.0.0      #将版本推送到服务器
git push origin --tags      #推送所有标签

results matching ""

    No results matching ""