Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

git

git-branch

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?

like image 844
user561638 Avatar asked Jul 12 '11 15:07

user561638


People also ask

What is a remote branch?

Git checkout remote branch is a way for a programmer to access the work of a colleague or collaborator for the purpose of review and collaboration. There is no actual command called “git checkout remote branch.” It's just a way of referring to the action of checking out a remote branch.

What is remote name and branch name in git?

REMOTE-NAME is the name of your remote repository. For example: origin. BRANCH-NAME is the name of your branch. For example: develop.

How do I change the name of my remote branch?

To be precise, renaming a remote branch is not direct – you have to delete the old remote branch name and then push a new branch name to the repo. Step 2: Reset the upstream branch to the name of your new local branch by running git push origin -u new-branch-name .


2 Answers

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

like image 126
Richard Hansen Avatar answered Oct 05 '22 12:10

Richard Hansen


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
like image 38
ghbarratt Avatar answered Oct 05 '22 10:10

ghbarratt