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?
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.
REMOTE-NAME is the name of your remote repository. For example: origin. BRANCH-NAME is the name of your branch. For example: develop.
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 .
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With