已删除的Git标签可以自行恢复 [英] Deleted Git tags restore themselves
问题描述
我们最近在Git仓库中遇到了一个标签问题。
我们在本地和远程删除了标签,但每次我们推送到或从远程获取。
我们目前正在一个由三人组成的团队中工作,当我们认为我们实际上已经摆脱了标签,有人会推进,我们都再次获得他们。
p>我们都试过:
git tag -d 12345
git push origin:refs / tags / 12345
其他人遇到此问题?
再次删除标签,然后执行此操作: $ c>#验证标签已从另一台计算机中移除
git fetch --all --prune
重要$>
如果您使用的是旧版本的git < 2.0
git push without branch name可能会推送您的所有分支和放大器;标签
到远程。验证这不是这种情况。
还有什么可以的你试试吗?
/ tags / ...
git push origin:标记名
#与上面相同,但使用`--delete`标志而不是`:`
git push --delete原产地标记名
#你已经在本地做过 - 删除标签以及
git tag -d标记名
Git钩子
验证是否没有git钩子会阻止您删除标签。
这是一个示例钩子:
#!/ bin / sh
log(){printf'%s \\\
'$ *; }
error(){logERROR:$ *>& 2; }
fatal(){error$ *;出口1; }
$ b $ case $ 1
refs / tags / *)
[$ 3!= 0000000000000000000000000000000000000000] \
||致命的你不允许删除标签
[$ 2= 0000000000000000000000000000000000000000] \
||致命的你不能移动标签
;;
#personal touch :-)
echo
echo| ZZzzz
echo|
echo|
echo| ZZzzz / ^ \ | ZZzzz
echo| | ~~~ | |
echo| | - - | / \
echo/ ^ \ | [] + | | ^^^ |
echo| ^^^^^^^ | | + [] | | |
echo| + [] | / \ / \\ \\ / \ / \ ^ / \ / \ / \ / \ / | ^^^^^^^ |
echo| + [] + | ~~~~~~~ ~~~~~~~~~~~ | + [] |
echo| | [] / ^ \ [] | + [] + |
echo| + [] + | [] || || [] | + [] + |
echo| [] + | || || | [] + |
echo| _______ | --- --------------- | _______ |
echo
echo
echo这是您上次尝试
echo删除或移动标签的时间。 :-)
echo
esac
Git v2.0发行说明
向后兼容性说明
当
git push [$ there]
没有说明要推送什么内容时,我们使用
传统的匹配
到目前为止(只要已经有分支同名
)在Git 2.0中,现在缺省是简单
语义,
推动:
只有当前分支具有相同的名称,并且当前分支设置时只有
与远程
分支进行整合,如果您要从同一个远程获取;或
只有当前分支到分支同名,如果你
a您可以使用配置变量<$ c。您可以使用配置变量<$ c。 $ c> push.default 更改
this。如果您是一位希望继续使用
匹配
语义的老前辈,则可以设置对于
示例,匹配
的变量。阅读文档以了解其他可能性。
We recently ran into an issue with tags in our Git repository.
We deleted our tags locally and remotely, yet they kept restoring itself every time we either push to or fetch from remote.
We are currently working in a team of three and when we think we actually got rid of the tags, someone would do a push and we all get them again.
We all tried:
git tag -d 12345
git push origin :refs/tags/12345
Anyone else ran into this issue?
Delete the tags again and then do this:
# verify that the tag was removed form another computer
git fetch --all --prune
Important
If you are on an older version of git <2.0
git push without branch name might push all your branches & tags
to the remote. Verify that this is not the case here.
What else can you try?
# push just the tag name without refs/tags/...
git push origin :tagname
# same as above but with the `--delete` flag instead of `:`
git push --delete origin tagname
# as you already did locally - delete the tag as well
git tag -d tagname
Git hooks
Verify that there are no git hooks which block you from delete the tags.
Here is a sample hook which do it:
#!/bin/sh
log() { printf '%s\n' "$*"; }
error() { log "ERROR: $*" >&2; }
fatal() { error "$*"; exit 1; }
case $1 in
refs/tags/*)
[ "$3" != 0000000000000000000000000000000000000000 ] \
|| fatal "you're not allowed to delete tags"
[ "$2" = 0000000000000000000000000000000000000000 ] \
|| fatal "you're not allowed to move tags"
;;
# personal touch :-)
echo " "
echo " |ZZzzz "
echo " | "
echo " | "
echo " |ZZzzz /^\ |ZZzzz "
echo " | |~~~| | "
echo " | |- -| / \ "
echo " /^\ |[]+ | |^^^| "
echo " |^^^^^^^| | +[]| | | "
echo " | +[]|/\/\/\/\^/\/\/\/\/|^^^^^^^| "
echo " |+[]+ |~~~~~~~~~~~~~~~~~~| +[]| "
echo " | | [] /^\ [] |+[]+ | "
echo " | +[]+| [] || || [] | +[]+| "
echo " |[]+ | || || |[]+ | "
echo " |_______|------------------|_______| "
echo " "
echo " "
echo " This is your last time trying to "
echo " delete or to move our tags. :-) "
echo " "
esac
Git v2.0 Release Notes
Backward compatibility notes
When
git push [$there]
does not say what to push, we have used the traditionalmatching
semantics so far (all your branches were sent to the remote as long as there already are branches of the same name over there). In Git 2.0, the default is now thesimple
semantics, which pushes:
only the current branch to the branch with the same name, and only when the current branch is set to integrate with that remote branch, if you are pushing to the same remote as you fetch from; or
only the current branch to the branch with the same name, if you are pushing to a remote that is not where you usually fetch from.
You can use the configuration variable
push.default
to change this. If you are an old-timer who wants to keep using thematching
semantics, you can set the variable tomatching
, for example. Read the documentation for other possibilities.
这篇关于已删除的Git标签可以自行恢复的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!