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

前端 未结 5 1156

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 

        
相关标签:
5条回答
  • 2020-12-17 18:52

    If you have access to the remote repository

    cd /path/to/remote/repository
    git config --bool core.bare true
    
    0 讨论(0)
  • 2020-12-17 18:54

    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.

    0 讨论(0)
  • 2020-12-17 18:54

    I had the same problem. I cloned from a bare repo and tried to use 'git tag' in that cloned repo, and that is where I was getting the error. To fix it I had to at least one push up to master before I could begin tagging. Hope this helps.

    0 讨论(0)
  • 2020-12-17 18:55

    I also faced git tag: fatal: Failed to resolve 'HEAD' as a valid ref issue when I was missing -m in the following command.(during tag creation)

    git tag -a testtag 'test'
    

    changing to

    git tag -a testtag -m 'test'
    

    fixed the issue

    0 讨论(0)
  • 2020-12-17 19:08

    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 :-)

    0 讨论(0)
提交回复
热议问题