如何浅度克隆深度为1的特定提交? [英] How to shallow clone a specific commit with depth 1?

查看:88
本文介绍了如何浅度克隆深度为1的特定提交?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在存储库中浅层克隆特定的提交,即深度为1?类似于

Is it possible to shallow clone a specific commit in a repository, i.e. with depth 1? Something like

git clone http://myrepo.git 728a4d --depth 1

以提交SHA 728a4d ... 的方式获取存储库状态?

to get the repository state as it is at the commit with SHA 728a4d...?

动机是避免克隆整个存储库,然后检查那个特定的提交,当我们只关心特定提交时的存储库状态。

The motivation is to avoid having to clone the whole repository, then check out that specific commit, when we're only interested in the state of the repository at that specific commit.

推荐答案

git init
git remote add origin <url>
git fetch --depth 1 origin <sha1>
git checkout FETCH_HEAD

请注意,我没有找到用 git clone 直接。

Note that I did not find a syntax to do this with git clone directly.

这篇关于如何浅度克隆深度为1的特定提交?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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