git fetch的默认远程 [英] Default remote for git fetch

查看:73
本文介绍了git fetch的默认远程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我在不是 跟踪任何远程分支的本地分支上,我会给出命令

If I am on a local branch that is not tracking any remote branch and I give the command

git fetch

鉴于我在$GIT_DIR/config中定义了几个遥控器,请从哪个遥控器进行抓取?

Given I have several remotes defined in $GIT_DIR/config, from which remote is the fetch done?

我试图从手册页中找到,但是我不清楚这一点.

I tried to find out from the man page, but this point is unclear to me.

另外:如何在不进行本地分支跟踪的情况下更改此默认遥控器?

Additionally: How can I change this default remote without making the local branch tracking?

推荐答案

如果您有多个远程存储库,并且未指定任何远程存储库名称,则默认情况下将使用origin.如果没有名为origin的远程存储库,它将错误提示

If you have multiple remote repositories, and don't specify any remote repository name, origin will be used by default. If there is no remote repository named origin, then it will error out saying

fatal: No remote repository specified.  Please, specify either a URL or a
remote name from which new revisions should be fetched.

另外:如何在不进行本地分支跟踪的情况下更改此默认遥控器?

Additionally: How can I change this default remote without making the local branch tracking?

您可以将该存储库名称重命名为"origin"以使其默认.

You can rename that repository name to 'origin' to make it default.

小心:如果当前分支已经在另一个远程服务器上指定了上游,则此操作将无效.
git help fetch:

Careful: this won't work if the current branch already has an upstream specified on a different remote.
From git help fetch:

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

When no remote is specified, by default the origin remote will be used, unless there’s an upstream branch configured for the current branch.

在这种情况下,您可以通过编辑.git/config中配置的分支的remote字段,将上游分支更改为使用origin.

In this case, you can change the upstream branches to use origin by editing the remote fields for branches configured in .git/config.

这篇关于git fetch的默认远程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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