Git浅获取新标签 [英] Git shallow fetch of a new tag

查看:100
本文介绍了Git浅获取新标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我在一个标签处克隆最大深度为1的存储库,它将正常工作并且将其删除.然后,如果我想对新标签进行深度为1或不具有1的访存,它会进行一些处理,但标签永远不会显示在"git tag"下.如果我提供--tags选项,它将下载整个存储库,而不仅仅是新信息.我不介意存储库有更多历史记录,我只是想避免下载时间.有什么方法可以在不从浅克隆存储库中获取所有标签的情况下获取新标签的?

If I clone a repository with max depth of 1 at a tag, it works and pulls down just that. If I then want to do a fetch with or without depth of 1 for a new tag, it does some processing, but the tag never shows up under 'git tag'. If I supply the --tags option, it downloads the whole repository rather than just the new information. I don't mind the repository getting more history, I just want to avoid the download times. Is there any way to get a new tag without getting all tags from a shallow cloned repository?

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

现在,我在文档中注意到了这一点: "- 深度 ... 无法获取用于深化提交的标记."

Now, I have noticed this in the documentation: "--depth ... Tags for the deepened commits are not fetched."

这是我正在遇到的吗?除了下载所有标签,没有其他方法吗?

Is this what I'm running into? Is there no way to do this besides downloading all tags?

推荐答案

您可以使用完整的<refspec>格式:

You can use the full <refspec> format:

git fetch --depth 1 origin refs/tags/1.1:refs/tags/1.1

或者,如 git-fetch选项(在<refspec>下)中所指定):

Or, as specified in git-fetch options (under <refspec>):

tag <tag> 的含义与 refs/tags/<tag>:refs/tags/<tag> 相同;它 请求将所有内容都提取到给定标签.

tag <tag> means the same as refs/tags/<tag>:refs/tags/<tag>; it requests fetching everything up to the given tag.

因此,您的问题的简短答案是

So the short form answer to your question would be

git fetch --depth 1 origin tag 1.1

这篇关于Git浅获取新标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆