博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
[转] [Gerrit] [Git] 新增/刪除tag
阅读量:4041 次
发布时间:2019-05-24

本文共 2102 字,大约阅读时间需要 7 分钟。

1). 在local端新增tag,如果commit_id为空,默认以最新的commit_id为准

$ git tag -a [tag_name] [commit_id]$ git tag -a 1.0.1 -m '.' # 创建带附注的附注标签,m参数可选

2). 切换标签

$ git checkout 1.0.1      #跳转到某标签$ git show 1.0.1          #查看标签版本信息

这块需要注意一下,使用checkout切换到某标签时,git会提示你处于一个空分支,需要使用-b来创建一个分支,以便进行分支管理。

$ git tag -a tag_temp a8a7d63d887bc65c23d0407c2569dc2f796b06a8   # 在某个commit_id上创建tag,写注释$ git tag                                                        # 查看tag$ git checkout tag_temp                                          # 切换到指定tag,git会提示你如下Note: checking out 'tag_temp'.You are in 'detached HEAD' state. You can look around, make experimentalchanges and commit them, and you can discard any commits you make in thisstate without impacting any branches by performing another checkout.If you want to create a new branch to retain commits you create, you maydo so (now or later) by using -b with the checkout command again. Example:  git checkout -b 
HEAD is now at a8a7d63... xxxxx$ git checkout -b temppp                                   # 在tag到临时分支上创建本地分支

或者直接根据tag创建分支

$ git checkout -b bugfix-tempp tag_temp

3). 在remote端新增tag

$ git push origin [tag_name]$ git push origin --tag      # 一次將所有tag push上去

4). 在local端刪除tag

 $ git tag -d [tag_name]

5). 在remote端刪除tag

$ git push origin :refs/tags/[tag_name]

6). 后期打标签

你也可以对过去的提交打标签。 假设提交历史是这样的:

$ git log --pretty=oneline15027957951b64cf874c3557a0f3547bd83b3ff6 Merge branch 'experiment'a6b4c97498bd301d84096da251c98a07c7723e65 beginning write support0d52aaab4479697da7686c15f77a3d64d9165190 one more thing6d52a271eda8725415634dd79daabbc4d9b6008e Merge branch 'experiment'0b7434d86859cc7b8c3d5e1dddfed66ff742fcbc added a commit function4682c3261057305bdd616e23b64b0857d832627b added a todo file166ae0c4d3f420721acbb115cc33848dfcc2121a started write support9fceb02d0ae598e95dc970b74767f19372d61af8 updated rakefile964f16d36dfccde844893cac5b347e7b3d44abbc commit the todo8a5cbc430f1a9c3d00faaeffd07798508422908a updated readme

现在,假设在 v1.2 时你忘记给项目打标签,也就是在 “updated rakefile” 提交。 你可以在之后补上标签。 要在那个提交上打标签,你需要在命令的末尾指定提交的校验和(或部分校验和):

$ git tag -a v1.2 9fceb02

————————————————

转载地址:http://tpmdi.baihongyu.com/

你可能感兴趣的文章
2020年终总结
查看>>
Homebrew指令集
查看>>
React Native(一):搭建开发环境、出Hello World
查看>>
React Native(二):属性、状态
查看>>
JSX使用总结
查看>>
React Native(四):布局(使用Flexbox)
查看>>
React Native(七):Android双击Back键退出应用
查看>>
Android自定义apk名称、版本号自增
查看>>
adb command not found
查看>>
Xcode 启动页面禁用和显示
查看>>
【剑指offer】q50:树中结点的最近祖先
查看>>
二叉树的非递归遍历
查看>>
【leetcode】Reorder List (python)
查看>>
【leetcode】Linked List Cycle (python)
查看>>
【leetcode】Linked List Cycle (python)
查看>>
【leetcode】Candy(python)
查看>>
【leetcode】Clone Graph(python)
查看>>
【leetcode】Sum Root to leaf Numbers
查看>>
【leetcode】Pascal's Triangle II (python)
查看>>
java自定义容器排序的两种方法
查看>>