gpt4 book ai didi

git - 如何真正删除 git/SourceTree 上的标签

转载 作者:太空狗 更新时间:2023-10-29 13:10:49 26 4
gpt4 key购买 nike

我知道如何从 SourceTree 中删除标签。只需右键单击、删除并勾选“从所有 Remote 中删除标签”。然后它执行以下操作(为了便于阅读,我省略了标志 -c diff.mnemonicprefix=false -c core.quotepath=false):

git tag -d my_tag
git push -v origin :refs/tags/my_tag

这有效。

问题来了

一段时间后,其他开发人员之一将他们的功能分支推送到源,SourceTree 将自动将所有本地标签推送到远程服务器。这将重新创建我刚刚删除的标签。

我知道这个想法是标签不应该被删除,例如标记版本,但有时会发生错误。

有什么建议吗?

最佳答案

我找到的唯一解决方案是在您从远程删除标签后,简单地要求所有其他开发人员删除标签的本地副本。我找到了脚本帮助 here .

To put it simple, if you are trying to do something like git fetch -p -t, it will not work starting with git version 1.9.4.

However, there is a simple workaround that still works in latest versions:

git tag -l | xargs git tag -d # remove all local tags
git fetch -t # fetch remote tags

A one liner can be written as:

git tag -l | xargs git tag -d && git fetch -t

Alternative, you can add a new alias to your ~/.gitconfig file to make things shorter:

in ~/.gitconfig

[alias]

pt = !git tag -l | xargs git tag -d && git fetch -t

Now, you can simply call pt alias to prune local stale tags:

git pt

关于git - 如何真正删除 git/SourceTree 上的标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35334141/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com