標籤
- 建立標籤
git tag <標籤名> [提交ID]
- 顯示標籤
git tag
- 顯示標籤詳細資訊
git show <標籤名>
houbinbindeMacBook-Pro:git-demo houbinbin$ git branch
git_demo_1.1
git_demo_1.2
git_demo_bug_001
* master
houbinbindeMacBook-Pro:git-demo houbinbin$ git tag v1.0
houbinbindeMacBook-Pro:git-demo houbinbin$ git tag
v1.0
houbinbindeMacBook-Pro:git-demo houbinbin$ git show v1.0
commit 4069a0cc54ee97993850419a09b62023ee3fa711
Author: “houbb” <“1060732496@qq.com”>
Date: Mon Oct 10 22:48:07 2016 +0800
fix the bug
diff --git a/README.md b/README.md
index 5664a33..98be30e 100644
--- a/README.md
+++ b/README.md
@@ -1,3 +1,4 @@
> Hello Git
- git diff
-- git_demo_1.2
\ No newline at end of file
+- git_demo_1.2
+fix the bug
\ No newline at end of file
houbinbindeMacBook-Pro:git-demo houbinbin$ git log --pretty=oneline --abbrev-commit
4069a0c fix the bug
0d899d1 merge with --no-ff
8983fd1 change git_demo_1.2
d696904 add pom.xml
cd84e27 git diff
9f18a0c add readme
965cf5d first commit
houbinbindeMacBook-Pro:git-demo houbinbin$ git tag v0.9 0d899d1
houbinbindeMacBook-Pro:git-demo houbinbin$ git tag
v0.9
v1.0
houbinbindeMacBook-Pro:git-demo houbinbin$ git show tag v0.9
fatal: ambiguous argument 'tag': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
houbinbindeMacBook-Pro:git-demo houbinbin$ git show v0.9
commit 0d899d1e9fa22bc3d8092d4a709abc0174186f79
Merge: d696904 8983fd1
Author: “houbb” <“1060732496@qq.com”>
Date: Mon Oct 10 22:29:49 2016 +0800
merge with --no-ff
- 新增包含資訊的標籤
git tag -a <標籤名> -m "資訊"
<提交ID>
houbinbindeMacBook-Pro:git-demo houbinbin$ git tag -a v0.1 -m "首次提交標籤" 965cf5d
houbinbindeMacBook-Pro:git-demo houbinbin$ git show v0.1
tag v0.1
Tagger: “houbb” <“1060732496@qq.com”>
Date: Mon Oct 10 23:11:05 2016 +0800
首次提交標籤
commit 965cf5db0b2ca8b062d2cd895b7431d37e11a23f
Author: houbinbin <1060732496@qq.com>
Date: Mon Oct 10 18:05:43 2016 +0800
first commit
- 新增帶有 PGP 簽名的標籤
git tag -s <標籤名> -m "簽名"
管理標籤
houbinbindeMacBook-Pro:git-demo houbinbin$ git tag
v0.1
v0.9
v1.0
houbinbindeMacBook-Pro:git-demo houbinbin$ git tag -d v0.1
Deleted tag 'v0.1' (was 0fc098a)
houbinbindeMacBook-Pro:git-demo houbinbin$ git push origin v0.9
計數物件: 4, 完成。
壓縮物件中: 100% (3/3), 完成。
寫入物件中: 100% (4/4), 442 bytes | 0 bytes/s, 完成。
總共 4 (delta 1),複用 0 (delta 0)
remote: Resolving deltas: 100% (1/1), completed with 1 local object.
To https://github.com/houbb/git-demo.git
* [new tag] v0.9 -> v0.9
houbinbindeMacBook-Pro:git-demo houbinbin$ git push origin --tags
計數物件: 3, 完成。
壓縮物件中: 100% (2/2), 完成。
寫入物件中: 100% (3/3), 361 bytes | 0 bytes/s, 完成。
總共 3 (delta 0),複用 0 (delta 0)
To https://github.com/houbb/git-demo.git
* [new tag] v1.0 -> v1.0
- 移除本地標籤
git tag -d <標籤名>
- 移除遠端標籤
git push origin :refs/tags/<標籤名>
本文由部落格一文多發平臺 OpenWrite 釋出!