Git 这个信息是什么意思?不止一个分支机构。<;名称>;。遥远的

Git 这个信息是什么意思?不止一个分支机构。<;名称>;。遥远的,git,git-branch,Git,Git Branch,在git remote show origin的输出中,我看到以下消息: warning: more than one branch.main_int.remote 一个更典型的例子是: warning: more than one branch.master.remote 这是什么意思?它坏了吗?如果坏了,我如何修复它?在配置文件的[branch“master”](或[branch“main_int”]部分中有多个远程=…设置。要查看此信息,请运行: git config --get-al

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

warning: more than one branch.main_int.remote
一个更典型的例子是:

warning: more than one branch.master.remote

这是什么意思?它坏了吗?如果坏了,我如何修复它?

在配置文件的
[branch“master”]
(或
[branch“main_int”]
部分中有多个
远程=…
设置。要查看此信息,请运行:

git config --get-all branch.master.remote
很可能这两行都在
.git/config
文件中。删除其中一行

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


该配置设置存储分支的上游存储库的名称,在键入
git push
git fetch
时使用该名称。一个分支只能有一个上游分支(例如,
master
可以跟随
origin/master
,但它也不能跟随
some\u other\u remote/master
)。

这意味着您的回购为分支配置了多个远程

我更愿意执行以下命令来纠正这种情况:

首先确保原点位置在手边。您可以使用
git remote show origin
或仅使用
git remote-v
查看当前为原点位置设置的内容

使用remote rm命令删除不必要的远程设备。例如,要删除源站远程使用:

git remote rm origin
此命令将删除名为“origin”的所有遥控器,因此,如果您有多个遥控器(如警告消息所示),则在此命令之后将没有遥控器。但此时,您可以通过以下方式重新添加一个:

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

谢谢大家!!我松了一口气!请注意,如果您也使用全局设置,则存储库配置中的一个
remote=…
设置可能会非常多。@Bengt:很好,谢谢。我更新了答案,提到了其他配置文件。