Git: distinguish between local and remote tags

后端 未结 2 1533
日久生厌
日久生厌 2021-02-01 16:32

If there are tags in the remote repository, I\'m usually getting them automatically when pulling. When I delete the created local tag (git tag -d )

2条回答
  •  终归单人心
    2021-02-01 17:28

    a tag isn't "local" or "remote": it is associated to a commit, which can part of multiple branches, including ones in the remotes namespace.

    Get tag SHA1 of the commit referenced by a tag

    git show -s 'TAG_NAME^{commit}' --format='%H'
    

    , and do a :

    git branch -a --contains SHA1
    

    If you see

     remotes/aRemoteRepoName/aBranch
    

    you know that tag references a commit you have fetched from a remote repo.

    As Chris mentions:

    git branch -a --contains TAGNAME
    

    will dereference the tag and gives the answer in one go.

提交回复
热议问题