简体   繁体   English

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

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

I saw a following line in a manifest file in .repo. 我在.repo的清单文件中看到以下行。 How can I do the same with the git command in manifest.xml? 如何使用manifest.xml中的git命令执行相同操作? I'd like to know how to run 'git clone' with specific revision and depth=1. 我想知道如何使用特定的修订版和depth = 1运行'git clone'。

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

If revision is a branch( refs/heads/xxx ) or a tag( refs/tags/xxx ), 如果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

If revision is a specific commit or a ref under other namepaces, not refs/tags/ or refs/heads/ , 如果revision是特定的提交或其他名称下的引用,而不是refs/tags/refs/heads/

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

Note that when revision is a specific commit at which no ref is pointing, git fetch would fail due to error: Server does not allow request for unadvertised object . 请注意,当revision是没有引用指向的特定提交时,由于error: Server does not allow request for unadvertised objectgit fetch将失败error: Server does not allow request for unadvertised object The variables in git config or the hosting service config allow to fetch an unadvertised object: git config或主机服务配置中的变量允许获取未发布的对象:

uploadpack.allowTipSHA1InWant
uploadpack.allowReachableSHA1InWant

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

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