创建标签
在Git中打標(biāo)簽非常簡單,首先,切換到需要打標(biāo)簽的分支上:
$ git branch * devmaster $ git checkout master Switched to branch 'master'然后,敲命令git tag <name>就可以打一個(gè)新標(biāo)簽:
$ git tag v1.0可以用命令git tag查看所有標(biāo)簽:
$ git tag v1.0默認(rèn)標(biāo)簽是打在最新提交的commit上的。有時(shí)候,如果忘了打標(biāo)簽,比如,現(xiàn)在已經(jīng)是周五了,但應(yīng)該在周一打的標(biāo)簽沒有打,怎么辦?
方法是找到歷史提交的commit id,然后打上就可以了:
$ git log --pretty=oneline --abbrev-commit 6a5819e merged bug fix 101 cc17032 fix bug 101 7825a50 merge with no-ff 6224937 add merge 59bc1cb conflict fixed 400b400 & simple 75a857c AND simple fec145a branch test d17efd8 remove test.txt ...比方說要對add merge這次提交打標(biāo)簽,它對應(yīng)的commit id是6224937,敲入命令:
$ git tag v0.9 6224937再用命令git tag查看標(biāo)簽:
$ git tag v0.9 v1.0注意,標(biāo)簽不是按時(shí)間順序列出,而是按字母排序的。可以用git show <tagname>查看標(biāo)簽信息:
$ git show v0.9 commit 622493706ab447b6bb37e4e2a2f276a20fed2ab4 Author: Michael Liao <askxuefeng@gmail.com> Date: Thu Aug 22 11:22:08 2013 +0800add merge ...可以看到,v0.9確實(shí)打在add merge這次提交上。
還可以創(chuàng)建帶有說明的標(biāo)簽,用-a指定標(biāo)簽名,-m指定說明文字:
$ git tag -a v0.1 -m "version 0.1 released" 3628164用命令git show <tagname>可以看到說明文字:
$ git show v0.1 tag v0.1 Tagger: Michael Liao <askxuefeng@gmail.com> Date: Mon Aug 26 07:28:11 2013 +0800version 0.1 releasedcommit 3628164fb26d48395383f8f31179f24e0882e1e0 Author: Michael Liao <askxuefeng@gmail.com> Date: Tue Aug 20 15:11:49 2013 +0800append GPL還可以通過-s用私鑰簽名一個(gè)標(biāo)簽:
$ git tag -s v0.2 -m "signed version 0.2 released" fec145a簽名采用PGP簽名,因此,必須首先安裝gpg(GnuPG),如果沒有找到gpg,或者沒有g(shù)pg密鑰對,就會(huì)報(bào)錯(cuò):
gpg: signing failed: secret key not available error: gpg failed to sign the data error: unable to sign the tag如果報(bào)錯(cuò),請參考GnuPG幫助文檔配置Key。
用命令git show <tagname>可以看到PGP簽名信息:
$ git show v0.2 tag v0.2 Tagger: Michael Liao <askxuefeng@gmail.com> Date: Mon Aug 26 07:28:33 2013 +0800signed version 0.2 released -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (Darwin)iQEcBAABAgAGBQJSGpMhAAoJEPUxHyDAhBpT4QQIAKeHfR3bo... -----END PGP SIGNATURE-----commit fec145accd63cdc9ed95a2f557ea0658a2a6537f Author: Michael Liao <askxuefeng@gmail.com> Date: Thu Aug 22 10:37:30 2013 +0800branch test用PGP簽名的標(biāo)簽是不可偽造的,因?yàn)榭梢则?yàn)證PGP簽名。驗(yàn)證簽名的方法比較復(fù)雜,這里就不介紹了。
小結(jié)
-
命令git tag <name>用于新建一個(gè)標(biāo)簽,默認(rèn)為HEAD,也可以指定一個(gè)commit id;
-
git tag -a <tagname> -m "blablabla..."可以指定標(biāo)簽信息;
-
git tag -s <tagname> -m "blablabla..."可以用PGP簽名標(biāo)簽;
-
命令git tag可以查看所有標(biāo)簽。
總結(jié)
- 上一篇: nginx基本数据结构ngx_modul
- 下一篇: H.264视频RTP负载格式/NALU的