Git tags are used for a wide variety of purposes. Let me record the relevant commands
Local Operations
Bash
#说明: 下文中的[]中的内容是选填的,可以无视方框内容,
# 也可以去掉方框选填其中内容
#查询
git tag
#增加
#0.
git tag [-f] your_tag_name [head(注)]
#1.
git tag [-f] your_tag_name [head] -m "your subject"
#2.
git tag [-f] your_tag_name [head] -a <CR>
...blablabla
# -f 是指强制更新
# -m 是指只加一个subject的标签
# -a 是指加一段文字的标签,打上-a 后,会跳出个文件让你写详细内容,
# 第一行是subject ,
# 第二行空,第三行开始写详述若需要的话
#删除
git tag -d tag_name
#重命名
#重命名一般是使用新建-删除组合
git tag [-f] new_tag_name old_tag_name
git tag -d old_tag_name
#另一种方法是,修改.git文件,修改.git/refs/tags/ 文件夹中文件名即可,比如
mv .git/refs/tags/new_tagname .git/refs/tags/old_tagname
#其他
git tag -h(Note) Here head refers to the first N characters of the hash string shown after git log (any length works, as long as the characters you enter are unambiguous). It can also be the name of another tag — for example, git tag tag1 tag2 works too.
Remote Operations
Bash
#general push
git push origin --tags
#它就是上传本地的tag设置,服务器不会删除本地已经删除的东西
#delete
git push origin :refs/tags/tag_to_delete
#它是 git push origin refs/tags/tag_local:refs/tags/tag_remote 的变体There must be a simpler way to delete a remote tag — if anyone knows, please help out.
Is it possible to force-push (like the -f mentioned above) and directly sync the local tag configuration to the server?
Comments
No comments yet — be the first to write one.