git-fetch命令

名称

git-fetch  - 从另一个存储库下载对象和引用

概要

git fetch [<options>] [<repository> [<refspec>…​]]
git fetch [<options>] <group>
git fetch --multiple [<options>] [(<repository> | <group>)…​]
git fetch --all [<options>]

描述

从一个或多个其他存储库中获取分支和/或标签(统称为“ refs”),以及完成其历史记录所需的对象。 Remote-tracking 分支已更新(有关控制此行为的方法,请参见下面的<refspec>描述)。

默认情况下,任何指向要获取的历史记录的标签tag也会被获取; 效果是获取指向您感兴趣的分支的标签。

可以使用--tags或--no-tags选项或配置remote <name>  tagOpt来更改此默认行为。

通过使用显式地获取标签的refspec,您也可以获取不指向您感兴趣的分支的标签。

git fetch可以从单个命名存储库或URL进行获取,也可以一次从多个存储库获取(如果给出了<group>并且配置文件中有一个remotes <group>条目)。

如果未指定远程,默认情况下origin将使用远程,除非为当前分支配置了上游分支。

所获取的refs的名称以及它们指向的对象名称将写入.git/ FETCH_HEAD。 脚本或其他git命令(例如git-pull [1])可以使用此信息。

选项<options>

--all

获取所有远程分支。

-a   --append

Append ref names and object names of fetched refs to the existing contents of .git/FETCH_HEAD. Without this option old data in .git/FETCH_HEAD will be overwritten.

将获取的引用的引用名称和对象名称附加到.git / FETCH_HEAD的现有内容中。 如果没有此选项,.git / FETCH_HEAD中的旧数据将被覆盖。

--depth=<depth>

将提取限制为从每个远程分支历史记录的提示中指定的提交数量。如果获取到使用git clone--depth=<depth>选项 创建的shallow存储库(请参阅 git-clone [1]),请将历史记录加深或缩短为指定的提交数。深化提交的标签不会被提取。

--deepen=<depth>

与 --depth 相似,只是它指定了来自当前浅层边界而不是每个远程分支历史记录的提示的提交数。

-p   --prune

Before fetching, remove any local tags that no longer exist on the remote if --prune is enabled. This option should be used more carefully, unlike --prune it will remove any local references (local tags) that have been created. This option is a shorthand for providing the explicit tag refspec along with --prune, see the discussion about that in its documentation.

在提取之前,请删除远程不再存在的所有远程跟踪参考。

-n   --no-tags

By default, tags that point at objects that are downloaded from the remote repository are fetched and stored locally. This option disables this automatic tag following. The default behavior for a remote may be specified with the remote.<name>.tagOpt setting.

-q   --quiet

将--quiet传递给git-fetch-pack并静音任何其他内部使用的git命令。 进展不会报告给标准错误流。

-v   --verbose

详细。

--progress

当连接到终端时,默认情况下,标准错误流中会报告进度状态,除非指定了 -q 。即使标准错误流未定向到终端,此标志也会强制进度状态。

--set-upstream

If the remote is fetched successfully, pull and add upstream (tracking) reference, used by argument-less git-pull[1] and other commands. For more information, see branch.<name>.merge and branch.<name>.remote in git-config[1].

如果成功获取了remote分支,拉取(pull)并添加上游(跟踪)引用,该引用由无参数的git-pull [1]和其他命令使用。 有关更多信息,请参见git-config [1]中的branch.<name> .merge和branch.<name> .remote。

仓库<repository>

作为提取或拉取操作源的“远程”存储库。此参数可以是 URL(请参阅下面的 GIT URLS 部分)或远程名称(请参阅下面的 REMOTES 部分)。

<group>

名称指的是存储库列表,作为配置文件中的远程数据 <group> 的值。(请参阅 git-config [1])。

发布了218 篇原创文章 · 获赞 135 · 访问量 137万+

猜你喜欢

转载自blog.csdn.net/ystyaoshengting/article/details/104043796