Git Tag 操作
查看Tag
// 查看tag
guyue@GuYue-MacBook-Pro13:~/kafka-test (master*=) % git tag
prod-tag-kafka-test-20191016112240-guyue
prod-tag-kafka-test-20191016112826-guyue
prod-tag-kafka-test-20191112145055-guyue
prod-tag-kafka-test-20191112150808-guyue
prod-tag-kafka-test-20191112150836-guyue
prod-tag-kafka-test-20191113105332-guyue
prod-tag-kafka-test-20191212210900-guyue
prod-tag-kafka-test-20191212210955-guyue
// 查看符合条件的 tag
guyue@GuYue-MacBook-Pro13:~/kafka-test (master*=) % git tag -l '*201910*'
prod-tag-kafka-test-20191016112240-guyue
prod-tag-kafka-test-20191016112826-guyue
// 查看 tag 改变的内容
guyue@GuYue-MacBook-Pro13:~/kafka-test (master*=) % git show prod-tag-kafka-test-20191016112240-guyue
创建Tag
tag 需要单独创建,并单独推送至远程服务器。而且Tag 也可以给之前push的版本打标签,不一定非得是当前版本。
// 创建tag
git tag 'new_tag_name'
// 将 tag 推送到远程服务器
git push origin new_tag_name[本地Tag名]:new_tag_name[远程Tag]名.
guyue@GuYue-MacBook-Pro13:~/kafka-test (master*%=) % git push origin 'test_tag'
Total 0 (delta 0), reused 0 (delta 0)
To http://gittest.net/kafka_test.git
* [new tag] test_tag -> test_tag
// 给某个 push 版本单独打标签
git tag -a test_old_push 98d2d63
guyue@GuYue-MacBook-Pro13:~/kafka_test (master*%=) % git push origin test_old_push:test_old_push
remote: git remote set-url origin http://gittest.net/kafka_test.git
To http://gittest.net/kafka_test.git
* [new tag] test_old_push -> test_old_push
删除Tag
删除 Tag 分为删除本地 Tag,删除远程 Tag。
// 删除本地 Tag
guyue@GuYue-MacBook-Pro13:~/kafka-test (master*%=) % git tag -d test_tag
Deleted tag 'test_tag' (was 49f3822)
// 删除远程 Tag
guyue@GuYue-MacBook-Pro13:~/kafka-test % git push origin :test_tag
To http://gittest.net/kafka_test.git
- [deleted] test_tag