[英]What is git-repo init and git-repo sync?
I'm using Google's git-repo plugin. 我正在使用谷歌的git-repo插件。 According to my understanding
repo sync
will download the whole source code (ie previous revisions) from the repository. 根据我的理解,
repo sync
将从存储库下载整个源代码(即先前的修订版)。 That is why it is taking a lot of time to complete this whole process. 这就是为什么要花费大量时间来完成整个过程的原因。
Can we download only the latest commit from the repository? 我们可以只从存储库下载最新的提交吗?
I don't use repo, but it appears that you can pass the --depth
flag to repo init
. 我不使用repo,但似乎你可以将
--depth
标志传递给repo init
。 Using something like repo init -u URL --depth=1
. 使用
repo init -u URL --depth=1
。 The depth flag gets passed to git-clone
and create a repo with only part of the history: 深度标志被传递给
git-clone
并创建一个仅包含部分历史记录的repo:
--depth <depth>
Create a shallow clone with a history truncated to the specified number of revisions.
创建一个浅层克隆,其历史记录被截断为指定的修订数。 A shallow repository has a number of limitations (you cannot clone or fetch from it, nor push from nor into it), but is adequate if you are only interested in the recent history of a large project with a long history, and would want to send in fixes as patches.
浅存储库有许多限制(您不能克隆或获取它,也不能从中推送或插入它),但如果您只对历史悠久的大型项目的近期历史感兴趣并且希望将修补程序作为补丁发送。
Yes, by default git fetch
(which is part of what git clone
does) will fetch the complete history of the remote repository. 是的,默认情况下
git fetch
(这是git clone
一部分)将获取远程存储库的完整历史记录。
You can limit the amount of history that is retrieved by using the --depth
option of the fetch command (clone will pass that on to fetch). 您可以使用fetch命令的
--depth
选项限制检索的历史记录量(克隆会将其传递给fetch)。 To retrieve the minimal amount of history you could use: 要检索最少的历史记录,可以使用:
git clone --depth 1 REPO_URL
This would retrieve the latest commit and the one(s) immediately preceding it, but not older commits. 这将检索最新的提交和紧接其之前的提交,但不会检索较早的提交。 It isn't possible to retrieve just the latest commit, since a depth of 0 is taken as wanting the full history;
不可能只检索最新的提交,因为深度为0被视为需要完整的历史记录; but this is close.
但这很接近。
Later you can use git fetch
with a larger depth to increase the amount of available history, or use git fetch --unshallow
to retrieve the complete history. 稍后您可以使用更大深度的
git fetch
来增加可用历史记录的数量,或者使用git fetch --unshallow
来检索完整的历史记录。
There are currently a number of limitations on shallow repositories. 目前,浅层存储库有很多限制。 The docs for
git clone --depth
say: git clone --depth
的文档说:
A shallow repository has a number of limitations (you cannot clone or fetch from it, nor push from nor into it), but is adequate if you are only interested in the recent history of a large project with a long history, and would want to send in fixes as patches.
浅存储库有许多限制(您不能克隆或获取它,也不能从中推送或插入它),但如果您只对历史悠久的大型项目的近期历史感兴趣并且希望将修补程序作为补丁发送。
Although there has recently been work on reducing or perhaps even removing those limitations. 尽管最近已经开始努力减少甚至消除这些限制。
What you are looking for is probably git pull
See the docs . 您正在寻找的可能是
git pull
请参阅文档 。 You first need to add your github repository as a remote host: 您首先需要将github存储库添加为远程主机:
git remote add master git@github.com:username/repository.git
Afterwards you can pull from the repository. 之后,您可以从存储库中提取。 On github there is also a link to download any commit as a
.zip
file. 在github上,还有一个链接可以将任何提交下载为
.zip
文件。 Format for that is usually: 格式通常是:
https://github.com/username/repository/archive/master.zip
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.