如果我在标签处克隆一个最大深度为 1 的存储库,它就可以正常工作并下 pull 。如果然后我想为新标签进行深度为 1 或不为 1 的提取,它会进行一些处理,但该标签永远不会显示在“git 标签”下。如果我提供 --tags 选项,它会下载整个存储库而不仅仅是新信息。我不介意存储库获得更多历史记录,我只是想避免下载时间。有没有办法在不从浅克隆存储库获取所有标签的情况下获取新标签?
git clone --branch 1.0 --depth 1 repositoryPath
git fetch --depth 1 origin tags/1.1 # Does processing but no new tags
git fetch --tags origin tags/1.1 # Pulls down the rest of the repository and adds all tags
git fetch --depth 1 --tags origin tags/1.1 # Same as above
现在,我在文档中注意到了这一点: “- 深度 ... 未获取加深提交的标签。”
这是我遇到的问题吗?除了下载所有标签之外没有办法做到这一点吗?
最佳答案
您可以使用完整的 <refspec>
格式:
git fetch --depth 1 origin refs/tags/1.1:refs/tags/1.1
或者,如 git-fetch options 中指定的那样(在 <refspec>
下):
tag <tag>
means the same asrefs/tags/<tag>:refs/tags/<tag>
; it requests fetching everything up to the given tag.
所以你的问题的简短答案是
git fetch --depth 1 origin tag 1.1
关于Git 浅获取新标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26617862/