Git 浅获取新标签

标签 git shallow-clone

如果我在标签处克隆一个最大深度为 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 as refs/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/

相关文章:

windows - 滚动时 msysgit 中的乱码文本

从接收后 Hook 更新 Git 子模块

git - 如何保持两个 git 存储库同步?

javascript - 在 Github 存储库中包含其他 CSS/JS 库的最佳方式?

git - Github CLI 错误 : must be on a branch named differently than "master"

混帐克隆 : warning: --depth is ignored in local clones; use file://instead

git - 如何浅克隆深度为 1 的特定提交?

git - 通过 https 克隆最新版本的 git 存储库

git - 使浅层 GIT 存储库不那么浅

git - 如何浅克隆特定分支上的 repo 协议(protocol)?