问题描述
如果我在不是 跟踪任何远程分支的本地分支上,我会给出命令
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.
您可以将该存储库名称重命名为"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
:
在这种情况下,您可以通过编辑.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的默认远程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!