繁体   English   中英

如何使用特定修订版和depth = 1进行git clone

[英]how to git clone with specific revision and depth=1

我在.repo的清单文件中看到以下行。 如何使用manifest.xml中的git命令执行相同操作? 我想知道如何使用特定的修订版和depth = 1运行'git clone'。

<project clone-depth="1" groups="pdk-cw-fs,pdk-fs" name="repository name" path="repository path" revision="SHA1"/>

如果revision是分支( refs/heads/xxx )或标签( refs/tags/xxx ),

git clone $remote -b $revision --depth=1 --single-branch
#or
git fetch $remote $revision --depth=1 && git checkout FETCH_HEAD

如果revision是特定的提交或其他名称下的引用,而不是refs/tags/refs/heads/

git fetch $remote $revision --depth=1 && git checkout FETCH_HEAD

请注意,当revision是没有引用指向的特定提交时,由于error: Server does not allow request for unadvertised objectgit fetch将失败error: Server does not allow request for unadvertised object git config或主机服务配置中的变量允许获取未发布的对象:

uploadpack.allowTipSHA1InWant
uploadpack.allowReachableSHA1InWant

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM