从“fetch --all”中排除git远程

问题描述 投票:1回答:3

是否可以在git中配置仅在其名称正式请求时获取的遥控器?所以他们将被排除在像fetch --all这样的行动之外。

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

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

(它被取出)

$ git fetch --all

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

git git-remote
3个回答
2
投票

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

git fetch也与团体合作,我更喜欢在处理团体时使用git remote,而我自己也喜欢使用git fetch作为一个个人遥控器。可能是十年以上的延续......)


1
投票

有一个配置skipFetchAll遥控器。

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

remote..skipFetchAll

如果为true,则在使用git-fetch [1]或git-remote [1]的update子命令进行更新时,默认情况下将跳过此远程。

由于在添加或更改遥控器时命令行没有选项,我必须将该配置编辑为.git/config文件,如下所示:

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

0
投票

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

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

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

© www.soinside.com 2019 - 2024. All rights reserved.