git标签管理

切换到master分支下,定义标签,查看标签

[root@localhost apeng]# git checkout master 
已经位于 'master'
[root@localhost apeng]# git tag v1.0
[root@localhost apeng]# git tag 
v1.0

查看标签v1.0的信息

[root@localhost apeng]# git show v1.0 
commit ec531a27522b5982a0d78efdddc836702e4d6498 //最新的commit
Author: apenglinux <[email protected]>
Date:   Fri Mar 23 22:20:50 2018 +0800

    Update 1.txt

diff --git a/1.txt b/1.txt
index 1fcd1df..5e9a0d7 100644
--- a/1.txt
+++ b/1.txt
@@ -1,2 +1,4 @@
 local
 modify-clone-file:1.txt
+I am server
+edit condition

查看commit

[root@localhost apeng]# git log --pretty=oneline
ec531a27522b5982a0d78efdddc836702e4d6498 Update 1.txt
0bede7e7e52302801bf34b41e7fbc76e550d9410 modify-1.txt
4bf800de22fdd5bf254c5e2757a3b348aed15d67 add 1.txt
34dd3f3c02f31e50e98baf1eb762e10dc8fbffc4 first commit

针对某一个commit创建一个标签

[root@localhost apeng]# git tag v0.8 0bede7e7e52302801bf34b41e7fbc76e550d9410

查看简写的commit

[root@localhost apeng]# git log --pretty=oneline --abbrev-commit
ec531a2 Update 1.txt
0bede7e modify-1.txt
4bf800d add 1.txt
34dd3f3 first commit

添加标签并增加解释说明

git tag -a v0.1 -m "first tat" 34dd3f3

删除标签

[root@localhost apeng]# git tag -d v0.1
已删除 tag 'v0.1'(曾为 2794836)

本地tag推送到远程

[root@localhost apeng]# git push origin v1.0 
Username for 'https://github.com': apenglinux
Password for 'https://[email protected]': 
Total 0 (delta 0), reused 0 (delta 0)
To https://github.com/apenglinux/apeng.git
 * [new tag]         v1.0 -> v1.0

推送所有标签到远程

[root@localhost apeng]# git push --tags origin

本地删除标签,服务端也要删除同一个标签

[root@localhost apeng]# git tag -d v0.8
[root@localhost apeng]# git push origin :refs/tags/v0.8