创建标签
git tag <tagname> commit id
省略 commit id 表示在当前分支的最新一次 commit 上打标签。创建带有说明的标签,用 -a 指定标签名,-m 指定说明文字,例如:
git tag -a <tagname> -m "tagmessage" commit id
效果如下所示:
$ git log
commit 196661aeb9309094f94a9f2daa37bd425964a733
Author: SoaringFree twofly0313@gmail.com
Date: Sat Dec 3 11:44:08 2016 +0800
Add I'am xxx
commit 77391b35c42d4feb3d69e0fa13595dcce836e524
Author: anyang xautanyang@163.com
Date: Sat Dec 3 11:00:45 2016 +0800
Add git push
commit b9df4072f8fbe352b38218f0aaf7508f48ceed19
Author: 安洋 1595949666@qq.com
Date: Sat Dec 3 10:43:15 2016 +0800
Initial commit
$ git tag V1.0
$ git show V1.0
commit 196661aeb9309094f94a9f2daa37bd425964a733
Author: SoaringFree twofly0313@gmail.com
Date: Sat Dec 3 11:44:08 2016 +0800
Add I'am xxx
diff --git a/README.md b/README.md
index 4237e04..f6e00ca 100644
--- a/README.md
+++ b/README.md
@@ -1,3 +1,5 @@
# LearnGit
Notes of Git learning
git push -u origin master
+I'm Fujingfei
$ git tag V2.0 77391b35c42
$ git show V2.0
commit 77391b35c42d4feb3d69e0fa13595dcce836e524
Author: anyang xautanyang@163.com
Date: Sat Dec 3 11:00:45 2016 +0800
Add git push
diff --git a/README.md b/README.md
index 22238ef..4237e04 100644
--- a/README.md
+++ b/README.md
@@ -1,2 +1,3 @@
# LearnGit
Notes of Git learning
+git push -u origin master
$ git tag -a V3.0 -m "tagmessage" b9df4072f8fbe352b
$ git show V3.0
tag V3.0
Tagger: anyang xautanyang@163.com
Date: Sun Dec 4 20:56:49 2016 +0800
tagmessage
commit b9df4072f8fbe352b38218f0aaf7508f48ceed19
Author: 安洋 1595949666@qq.com
Date: Sat Dec 3 10:43:15 2016 +0800
Initial commit
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..22238ef
--- /dev/null
+++ b/README.md
@@ -0,0 +1,2 @@
+# LearnGit
+Notes of Git learning
查看所有标签信息
git tag
效果如下所示:
$ git tag
V1.0
V2.0
V3.0
查看具体标签信息
git show <tagname>
效果如下所示:
$ git show V3.0
tag V3.0
Tagger: anyang xautanyang@163.com
Date: Sun Dec 4 20:56:49 2016 +0800
tagmessage
commit b9df4072f8fbe352b38218f0aaf7508f48ceed19
Author: 安洋 1595949666@qq.com
Date: Sat Dec 3 10:43:15 2016 +0800
Initial commit
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..22238ef
--- /dev/null
+++ b/README.md
@@ -0,0 +1,2 @@
+# LearnGit
+Notes of Git learning
删除本地标签
git tag -d <tagname>
效果如下所示:
$ git tag -d V2.0
Deleted tag 'V2.0' (was 77391b3)
$ git tag
V1.0
V3.0
推送某个标签到远程仓库
git push origin <tagname>
效果如下所示:
$ git push origin V1.0
Total 0 (delta 0), reused 0 (delta 0)
To git@github.com:anyangxaut/LearnGit.git
* [new tag] V1.0 -> V1.0
推送全部尚未推送到远程仓库的本地标签
git push origin --tags
效果如下所示:
$ git push origin --tags
Counting objects: 1, done.
Writing objects: 100% (1/1), 155 bytes | 0 bytes/s, done.
Total 1 (delta 0), reused 0 (delta 0)
To git@github.com:anyangxaut/LearnGit.git
* [new tag] V1.0 -> V1.0
* [new tag] V3.0 -> V3.0
删除远程标签
git push origin --delete <tagname>
效果如下所示:
$ git push origin --delete V1.0
To git@github.com:anyangxaut/LearnGit.git
- [deleted] V1.0
相关资料:
- Git 官网
- Git 官方文档
- [廖雪峰的 Git 教程](http://www.liaoxuefeng.com/wiki/0013739516305929606dd18361248578c67b8
067c8c017b000) - Git 常用命令查询文档
- Git 在线学习网址
网友评论