git fatal:没有标签可以描述

发布于 2024-11-16 20:28:36 字数 324 浏览 2 评论 0原文

我通过将标签应用于夜间构建来使用标签。然后,我想使用 describe --tags --match 的输出来告诉我图像距离夜间构建有多远。这是用于 QA 测试的。

我刚刚在比当前标签更旧的克隆中遇到错误。我运行了 git fetch --tags,所以我在 git tag 输出中看到了标签,但是当我运行 git describe --tags --match时,我得到了 fatal: No标签可以描述。此时我无法执行 git pull 来更新工作区。为什么会发生这种情况?有解决方法吗?非常感谢

I am using tags by applying them to nightly builds. Then later, I want to use the output of describe --tags --match <latest tag> to tell me how far from the nightly build my images are. This is for QA testing.

I just ran into an error in a clone that is older than the current tag. I ran git fetch --tags, so I see the tag in git tag output, but when I run git describe --tags --match <tagname>, I get fatal: No tags can describe <head sha1 version number>. I cannot do a git pull to update the workspace at this point. Why does this happen and is there a workaround? Thanks very much

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(7

凡间太子 2024-11-23 20:28:36

我刚刚使用 git version 2.8.3 和命令 gitdescribe --abbrev=0 遇到了这个错误。

问题是,虽然标签存在于源中并且我的本地存储库是最新的,但标签没有提交消息。

在我用标签消息重新标记提交后,错误得到解决:

git tag v1.1.1 -m 'some message'

I just ran into this error with git version 2.8.3 and command git describe --abbrev=0.

The problem was that while the tag existed in the origin and my local repository was up to date, the tag did not have a commit message.

The error was resolved after I re-tagged the commit with a tag message:

git tag v1.1.1 -m 'some message'
只有影子陪我不离不弃 2024-11-23 20:28:36

另一种解释可能是存储库是使用 depth=xyz 设置进行克隆的(Travis 默认情况下是这样的)。在这种情况下,历史记录可能会在最新标签之前被切断。

从技术上讲,使用深度=xyz克隆会创建一个浅克隆,其中的条目描述了在哪里切断历史记录。当 git describe 遍历历史记录时,它可能会到达该分界点并停止搜索标签。如果您在使用 git fetch --tags 进行初始浅克隆后手动获取标签,甚至会发生这种情况。

如果这是问题所在,您需要unshallow存储库(或者首先创建一个完整(足够)的克隆)。请参阅 如何将 Git 浅克隆转换为完整克隆? 来解决问题。

Another explanation can be that the repository was cloned with a depth=xyz setting (which Travis does by default). In that case, the history might be cut off before the most current tag.

Technically, cloning with depth=xyz creates a shallow clone with entries in .git/shallow that describe where to cut off history. When git describe then walks the history it might get to that cut-off point and stops searching for a tag. That even happens if you fetched tags manually after the initial shallow clone with git fetch --tags.

If this is the problem, you need to unshallow the repository (or create a full (enough) clone in the first place). See How to convert a Git shallow clone to a full clone? to solve the problem.

看海 2024-11-23 20:28:36

发生这种情况是因为您只获取标签,而不是标签的提交历史记录。 git describe 使用此历史记录,这就是它出现错误的原因。

唯一的解决方法是使用 git fetch来获取包含您感兴趣的标签的存储库历史记录。

It happens because you only fetch the tag, not the commit history of the tag. git describe uses this history, which is why it has an error.

The only workaround is to fetch repo's history containing the tag you're interested in, using git fetch <remote-name>.

无可置疑 2024-11-23 20:28:36

这可能有两个原因。

  1. 使用 actions/checkout 时缺少 fetch-depth: 0,因为它需要上一个标记提交之前的历史记录,如果您进行浅层提取,则可能会丢失该历史记录。
  2. 您正在非主分支上运行它,该分支自创建最后一个标签以来没有发生任何更改。执行 git pull 并将这些更改推送到远程并查看它是否正常工作。

There might be 2 reasons for this.

  1. The fetch-depth: 0 is missing while using actions/checkout since it requires the history upto the previous tag commit which might miss if you are doing shallow fetch.
  2. You are running it on a non-main branch which doesn't have the changes since the last tag is created. Do a git pull and push those changes to the remote and see if it is working.
人海汹涌 2024-11-23 20:28:36

当我基于 git 引用创建 git 标签时,我实际上遇到了这个错误。

看来 git 引用不是“在 master 中”,这会导致一些问题。

因此,解决方法是在 master 中找到正确的提交引用并重新创建标签。

I actually ran into this error when I have created a git tag based on git reference.

It seems that the git reference was not "in master" and this cause some problems.

So the fix was to find the proper commit reference in master and recreate the tag.

你对谁都笑 2024-11-23 20:28:36

对我来说,它在使用 git pull 而不是 git fetch 后起作用。

增强已提供的解决方案:我的 git 标签已经有标签消息,并且 git fetch对我的情况也没有帮助。

For me it worked after using git pull instead of git fetch.

Enhancing on the solutions already provided: My git tag already had a tag message and git fetch <remote-name> didn't help in my case as well.

情域 2024-11-23 20:28:36

我在进行 git checkout 时使用下面的标签解决了这个问题。
获取深度:'0'

I have solved this issue with using below tag while doing git checkout.
fetch-depth: '0'

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文