Git 操作标签的一些命令

如果标签打错了,也是可以删除:

$ git tag -d v0.1
Deleted tag 'v0.1' (was d96a49b)

 如果要推送某个标签到远程,使用git push orign tagname;

$ git push origin v0.2
Username for 'https://github.com': lvloveyuforever@gmail.com
Password for 'https://lvloveyuforever@gmail.com@github.com':
Counting objects: 1, done.
Writing objects: 100% (1/1), 805 bytes | 0 bytes/s, done.
Total 1 (delta 0), reused 0 (delta 0)
To https://github.com/LvLoveYuForever/gitskill.git
* [new tag] v0.2 -> v0.2

或者一次性推送全部尚未推送到远程的本地标签:

$ git push origin --tags

如果标签已经推送到远程,要删除远程标签就要麻烦一点,先从本地删除:

$ git tag -d v0.2

然后从远程删除,删除命令也是push,格式如下:

LV@LV-PC MINGW32 /c/gitskill (master)
$ git push origin :refs/tags/v0.2
Username for 'https://github.com': lvloveyuforever@gmail.com
Password for 'https://lvloveyuforever@gmail.com@github.com':
To https://github.com/LvLoveYuForever/gitskill.git
- [deleted] v0.2

原文地址:https://www.cnblogs.com/LvLoveYuForever/p/5525530.html