git tag:fatal:无法解析'HEAD'作为有效的参考 [英] git tag: fatal: Failed to resolve 'HEAD' as a valid ref

查看:2975
本文介绍了git tag:fatal:无法解析'HEAD'作为有效的参考的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从存储库克隆单个分支,并在python脚本中创建一个标签。这些命令如下。

I am cloning a single branch from a repository and creating a tag in a python script. The commands are as follows.

git clone -b master --single-branch <repository adress>

git tag -a testag -m 'test'

成功克隆但是在添加标签时,会出现以下错误:

It clones successfully but when it comes to adding the tag, it breaks with the following error:

fatal: Failed to resolve 'HEAD' as a valid ref.


推荐答案

我有同样的问题。您必须在标记前先提交

I had the same issue. You have to commit first before tagging

git commit

,因为您在提交时放置了标签。所以,当没有提交(就像你的情况),你不能创建一个标签。

because you put tags on commits. So when there is no commit (like in your situation), you can't create a tag.

这篇关于git tag:fatal:无法解析'HEAD'作为有效的参考的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆