24

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

warning: more than one branch.main_int.remote

A more canonical example would 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?

tshepang
  • 12,111
  • 21
  • 91
  • 136
user561638
  • 1,299
  • 3
  • 15
  • 26

2 Answers2

37

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).

Richard Hansen
  • 51,690
  • 20
  • 90
  • 97
  • Thank-you! I am so relieved! – user561638 Jul 12 '11 at 19:20
  • 4
    Note that *one* `remote = ...` setting in your repositories' config can be to much, if you have set it also globally using [`git config --global branch.master.remote origin`](http://stackoverflow.com/questions/658885/how-do-you-get-git-to-always-pull-from-a-specific-branch). – Bengt Jul 04 '13 at 22:48
  • @Bengt: Good point, thank you. I updated my answer to mention the other config files. – Richard Hansen Jul 05 '13 at 03:47
2

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
ghbarratt
  • 11,496
  • 4
  • 41
  • 41