Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Duplicate branches pointing to same upstream #2

Closed
michaeldfallen opened this issue Jul 14, 2015 · 1 comment
Closed

Duplicate branches pointing to same upstream #2

michaeldfallen opened this issue Jul 14, 2015 · 1 comment

Comments

@michaeldfallen
Copy link
Owner

When you have two branches point to the same upstream branch you get the following message:

fatal: ambiguous argument 'origin/branch                                                                                               
origin/branch...HEAD': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
fatal: ambiguous argument 'origin/branch
origin/branch...HEAD': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'

due to the remote_branch_name function having trouble finding which branch to follow

gburca added a commit to gburca/git-radar that referenced this issue Aug 27, 2015
When a branch has more than one upstream revision (ex: origin/master and
origin2/master), `remote_branch_name` returns multiple references
concatenated together causing the git error shown below:

fatal: ambiguous argument 'origin/masterorigin2/master...HEAD': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
fatal: ambiguous argument 'origin/masterorigin2/master...HEAD': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'

This patch just picks the first of the upstream branches. A full fix
would allow the user to decide which upstream to track.
@asaaki
Copy link

asaaki commented Aug 28, 2015

This also happens if you have some branch setup like following:

master
something/master

When working on master branch it also returns more than a single line.

My workaround in my case is:

# in radar-base.sh -> remote_branch_name()
local remoteBranch="$(git for-each-ref --format='%(upstream:short)' refs/heads $localRef 2>/dev/null | grep origin/$localRef)"

So, basically in the grep command prefix with origin/ is added.

(Unfortunately this breaks the nice branch diff output and stays on upstream ⚡ <branch>.)

In general, if you have two or more branches sharing identical suffixes, git-radar will fail for the branch without the prefix.

slackorama pushed a commit to slackorama/git-radar that referenced this issue Oct 2, 2015
Use `git config` to get the correct upstream remote and branch when you
have branch with the same name in multiple remotes (e.g. "origin/master"
and "coworker/master"). Uses awk which may be a problem?
slackorama pushed a commit to slackorama/git-radar that referenced this issue Oct 15, 2015
Use `git config` to get the correct upstream remote and branch when you
have branch with the same name in multiple remotes (e.g. "origin/master"
and "coworker/master"). Uses awk which may be a problem?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants