排除来自 "fetch --all" 的 git 远程

Excluding a git remote from "fetch --all"

是否可以在 git 中配置仅在通过其名称正式请求时才获取的遥控器?因此它们将被排除在 fetch --all.

之类的操作之外

想象一个名为 "my-no-auto-fetch-remote" 的休眠(禁用或其他)遥控器:

$ git fetch my-no-auto-fetch-remote

(已提取)

$ git fetch --all

(不应获取 my-no-auto-fetch-remote)

我会用 bash 技巧来做到这一点:

git remote | grep -v the-repo-i-dont-want | xargs git fetch

可能会把它变成脚本或 git 别名。

不完全是,不:--all 表示 所有 。但是您 可以 定义远程 ,并使用 git remote update 更新组。将通常不可用的遥控器放入非默认组的组中。有关详细信息,请参阅 the git remote documentation

(git fetch 也适用于群组,我只是更喜欢在处理群组时使用 git remotegit fetch 对于一个单独的遥控器,我自己。可能是十年后的遗留问题-再加上...)

有一个遥控器配置 skipFetchAll

来自以下文档:https://git-scm.com/docs/git-config/1.9.2

remote..skipFetchAll

If true, this remote will be skipped by default when updating using git-fetch[1] or the update subcommand of git-remote[1].

由于添加或更改遥控器时命令行没有选项,我不得不将该配置编辑 .git/config 文件,如:

[remote "my-remote"]
        url = git@the-repository-url
        fetch = +refs/heads/*:refs/remotes/my-remote/*
        skipFetchAll = true