git describe fails with “fatal: No names found, cannot describe anything.”

后端 未结 7 1981
梦如初夏
梦如初夏 2020-12-07 22:09

I\'m using git 1.7.1 on Ubuntu 10.10 amd64, and I\'m trying to extract the hash of my repository HEAD to use it in an automated version information that I compile into my pr

7条回答
  •  时光说笑
    2020-12-07 22:22

    This happens if you don't have any tags in your repository. If the repository does have tags, then you're in a shallow clone (this is the default in CI systems like TravisCI or GitHub Actions).

    To fetch the history (including tags) from within a shallow clone, run

    git fetch --prune --unshallow
    

    For example, in the case of GitHub actions:

    - uses: actions/checkout@v2
    - run: git fetch --prune --unshallow
    

    Afterwards, git describe should work again.

提交回复
热议问题