Checkout a tag from a private GitHub repository

前端 未结 3 973
星月不相逢
星月不相逢 2020-12-20 01:23

I need to clone a private repository from GitHub, but I only want to get a specific tag (so basically, cloning is actually the wrong term for it).

Now, the

3条回答
  •  Happy的楠姐
    2020-12-20 01:51

    git fetch --all --prune will update your local repository with all the latest branches and tags, once you have them locally you can simply check them out.

    After the fetch you can list the tags with git tag -l and then git checkout a specific tag: git checkout tags/

    Of course that you can also pull directly form the remote repo without fetching before.

    you need to keep in mind that in git there are 2 types of tags:

    • regular tag (a "real" git commit)
    • annotated tag (a movable SHA-1 to any commit that you wish to use it on)

    So if you checkout an annotated tag today it doesn't mean that if you checkout tag now it will be the same commit later on. keep it in mind

    If you want to clone the tip of the tag (just the last commit)

    git clone --branch --depth=1

提交回复
热议问题