1.管理标签
当版本仓库内的数据有个大的改善或者功能更新,我们经常会打一个类似于软件版本号的标签,这样通过标签就可以将版本库中的某个历史版本给记录下来,方便我们随时将特定历史时期的数据取出来用,另外打标签其实只是向某个历史版本做了一个指针,所以一般都是瞬间完成的,很方便
1.在Git中打标签非常简单,给最近一次提交的记录打个标签:
[root@test linuxprobe]# git tag v1.0 [root@test linuxprobe]# git tag v1.0
2.查看此标签的详细信息:
[root@test linuxprobe]# git show v1.0 commit 245824ddf8d70290fa7b7aa604529d58f542036d Author: xiejc <443060965@qq.com> Date: Fri Dec 29 01:11:44 2017 +0800 changed the file name again diff --git a/introduction.txt b/introduction.txt deleted file mode 100644 index 53eb420..0000000 --- a/introduction.txt +++ /dev/null @@ -1,6 +0,0 @@ -Initialization Git repository -Git is a distributed version control system. -Git is free software. -Git is a distributed version control system. -Something not important -Modified again diff --git a/readme.txt b/readme.txt new file mode 100644 index 0000000..53eb420 --- /dev/null +++ b/readme.txt @@ -0,0 +1,6 @@ +Initialization Git repository +Git is a distributed version control system. +Git is free software. +Git is a distributed version control system. +Something not important +Modified again
3.指定对应ID号
[root@test linuxprobe]# git log --pretty=oneline
245824ddf8d70290fa7b7aa604529d58f542036d changed the file name again
1aa44b7e4d3a989891f6de4544fa10b7d6a11196 changed name
[root@test linuxprobe]# git tag v1.1 1aa44b7
[root@test linuxprobe]# git tag
v1.0
v1.1
4.还可以创建带有说明的标签,用-a指定标签名,-m指定说明文字:
[root@test linuxprobe]# git tag -a v1.2 -m "version 1.1 released" 8ebd54f0 [root@test linuxprobe]# git tag v1.0 v1.1 v1.2
5.删除标签
[root@test linuxprobe]# git tag -d v1.0 Deleted tag 'v1.0' (was 245824d) [root@test linuxprobe]# git tag v1.1 v1.2
6.小结
- 命令
git tag <name>
用于新建一个标签,默认为HEAD
,也可以指定一个commit id; git tag -a <tagname> -m "blablabla..."
可以指定标签信息;git tag -s <tagname> -m "blablabla..."
可以用PGP签名标签;- 命令
git tag
可以查看所有标签。
如无特殊说明,文章均为本站原创,转载请注明出处
- 转载请注明来源:Git系列之三管理标签
- 本文永久链接地址:https://www.xionghaier.cn/archives/31.html