我有点困惑,为什么我无法直接从 git clone 命令 check out 标签。我尝试做的是:
git clone -b mytag <url>/foo.git
我得到的错误是:
warning: Remote branch mytag not found in upstream origin, using HEAD instead
标签存在,例如
cd foo && git checkout mytag
...效果很好。
如果有人能分享一些关于为什么不能直接克隆到标签中的信息,我将不胜感激。谢谢。
最佳答案
也许您真正需要/想要做的就是使用 git archive
pull 任何东西的压缩包git rev-parse
可以理解。您可以使用 --remote
与 <url>/foo.git
相同的从某个远程源提取存档的选项您传递给克隆的值。理论上,这会快得多,因为您将获取的只是工作树,而不是整个存储库。
这是一个“对我有用”的例子:
% git archive --prefix foo/ --remote <url>/foo.git my-tag | tar -xf -
关于git - 无法使用 -b <tagname> 直接克隆到 git 标签中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3438321/