开发者

what does this message mean? more than one branch.<name>.remote

In the output from git remote show origin, I see this message:

warning: more than one branch.main_int.remote

A more canonical example w开发者_Python百科ould be:

warning: more than one branch.master.remote

What does this mean? Is it bad, and how do I fix it, if it is bad?


You have more than one remote = ... setting in the [branch "master"] (or [branch "main_int"]) section of your config file(s). To see this, run:

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

Chances are both lines are in the .git/config file. Delete one of the lines.

If you only see one remote = ... line in your .git/config file, check your ~/.gitconfig, ~/.config/git/config, and /etc/gitconfig files. (The effective config for a repository is the concatenation of all of these files together.)

That configuration setting stores the name of the branch's upstream repository, which is used when you type git push or git fetch. A branch can only have one upstream branch (e.g., master can follow origin/master but it can't also follow some_other_remote/master).


This means that your repo is configured with multiple remotes for the branch.

I prefer to do the following commands to remedy this situation:

First make sure to have the origin location handy. You can use git remote show origin or just git remote -v to see what is currently set for the origin location.

Remove the unnecessary remotes with the remote rm command. For example, to remove the origin remote use:

git remote rm origin

This command will remove all the remotes with the name "origin" so if you had more than one, as your warning message seems to indicate, then you will have none after this command. But at this point you can add one back in with:

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜