这个消息是什么意思?多个分支。<name>.remote

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

git remote show origin
的输出中,我看到以下消息:

warning: more than one branch.main_int.remote

一个更典型的例子是:

warning: more than one branch.master.remote

这是什么意思?它是否坏了,如果坏了,我该如何解决?

git git-branch
3个回答
37
投票

您的配置文件的

remote = ...
(或
[branch "master"]
)部分中有多个
[branch "main_int"]
设置。要查看此内容,请运行:

git config --get-all branch.master.remote

很可能这两行都在

.git/config
文件中。删除其中一行。

如果您在

remote = ...
文件中只看到一行
.git/config
,请检查您的
~/.gitconfig
~/.config/git/config
/etc/gitconfig
文件。 (存储库的有效配置是将所有这些文件连接在一起。)

该配置设置存储分支上游存储库的名称,当您键入

git push
git fetch
时使用该名称。一个分支只能有一个上游分支(例如,
master
可以跟随
origin/master
,但不能跟随
some_other_remote/master
)。


2
投票

这意味着您的存储库为分支配置了多个遥控器。

我更喜欢执行以下命令来解决这种情况:

首先确保手头有起始位置。您可以使用

git remote show origin
或仅使用
git remote -v
查看当前为原点位置设置的内容。

使用remote rm 命令删除不必要的遥控器。例如,要删除原始远程使用:

git remote rm origin

此命令将删除所有名为“origin”的遥控器,因此,如果您有多个遥控器,正如您的警告消息似乎表明的那样,那么在此命令之后您将不会有任何遥控器。但此时您可以添加一个:

git remote add origin location:/to/origin/repo.git

0
投票

试试这个,我最近在 Windows 上使用它来解决同样的问题。

git remote rm origin
git remote add origin https://github.com/username/repository
git config --replace-all branch.master.remote origin
git config --unset branch.master.remote
© www.soinside.com 2019 - 2024. All rights reserved.