git 致命:没有标签可以描述 <sha1 number>
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6445148/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
git fatal:No tags can describe <sha1 number>
提问by user561638
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.
我通过将标签应用于每晚构建来使用标签。然后,我想使用 的输出describe --tags --match <latest tag>
来告诉我离每晚构建我的图像有多远。这是用于 QA 测试。
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
我刚刚在比当前标签更旧的克隆中遇到错误。我运行了 git fetch --tags,所以我在 git tag 输出中看到了标签,但是当我运行时git describe --tags --match <tagname>
,我得到了fatal: No tags can describe <head sha1 version number>
. 此时我无法执行 git pull 来更新工作区。为什么会发生这种情况,是否有解决方法?非常感谢
采纳答案by CharlesB
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.
发生这种情况是因为您只获取标签,而不是标签的提交历史。git describe
使用此历史记录,这就是它有错误的原因。
The only workaround is to fetch repo's history containing the tag you're interested in, using git fetch <remote-name>
.
唯一的解决方法是使用git fetch <remote-name>
.
回答by modle13
I just ran into this error with git version 2.8.3
and command git describe --abbrev=0
.
我刚刚用git version 2.8.3
and 命令遇到了这个错误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'
回答by jrudolph
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.
另一种解释可能是存储库是使用depth=xyz
设置克隆的(默认情况下 Travis 会这样做)。在这种情况下,历史记录可能会在最新标签之前被截断。
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
.
从技术上讲,cloning withdepth=xyz
创建了一个浅层克隆,其中的条目.git/shallow
描述了在何处切断历史记录。当然git describe
后遍历历史时,它可能会到达那个截止点并停止搜索标签。如果您在使用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.
如果这是问题,您需要unshallow
存储库(或首先创建一个完整(足够)的克隆)。请参阅如何将 Git 浅克隆转换为完整克隆?来解决问题。
回答by Valentin Despa
I actually ran into this error when I have created a git tag based on git reference.
当我基于 git 引用创建一个 git 标签时,我实际上遇到了这个错误。
It seems that the git reference was not "in master" and this cause some problems.
似乎 git 引用不是“在 master 中”,这会导致一些问题。
So the fix was to find the proper commit reference in master and recreate the tag.
所以修复是在 master 中找到正确的提交引用并重新创建标签。