Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git tag: fatal: Failed to resolve 'HEAD' as a valid ref

Tags:

git

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.
like image 470
Ahmad Avatar asked Oct 01 '13 12:10

Ahmad


2 Answers

I ran into the same issue and was able to fix it by changing from

git tag -a testtag -m 'test'

to

git tag -a testtag -m "test"

I was running in Windows 7. Hope this helps :-)

like image 149
sebastianr Avatar answered Sep 20 '22 09:09

sebastianr


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.

like image 41
Abdalla Mohamed Aly Ibrahim Avatar answered Sep 19 '22 09:09

Abdalla Mohamed Aly Ibrahim