创建tag
git tag [tagName]
将tag push到远程仓库
git push origin [tagName]
删除tag
git tag -d [tagName]
删除远端tag
git push origin :refs/tags/[tagName]
从tag创建一个分支
git checkout -b branch_name tag_name
今天遇到一个批量删除tag的需求,故写了一个脚本如下:
for tagName in `git tag`; do
if [ ${tagName:0:4} == "2014" ]; then
echo delete tag ${tagName}
git tag -d ${tagName}
git push origin :refs/tags/${tagName}
fi
done
其中${tagName:0:4}获取变量的前4个字符
网友评论