2

Just a disclaimer: After a few months of working with git, I still have literally no idea what I'm doing when I use it. The only time things work is when I exactly follow the instructions I find on the web on various pages.

What I'm trying to do is update my repository, which is forked from another project. I found that these instructions work and I have been following them every time I want to update

However, this time when I try to merge I get this:

warning: refname 'upstream/master' is ambiguous.
Already up-to-date

And nothing happens, even though the project from which I forked has made recent commits. I don't really know what went wrong, and I'm really frustrated. Sorry if this question is incredibly noobish and/or stupid.

EDIT 1: Also, I have searched for numerous solutions with no success.

EDIT 2: output of git branch -a

* master
upstream/master
remotes/origin/HEAD -> origin/master
remotes/origin/log-upgrade
remotes/origin/master
remotes/origin/past-gens
remotes/origin/prototype-party
remotes/upstream/log-upgrade
remotes/upstream/master
remotes/upstream/past-gens
remotes/upstream/prototype-party

EDIT 3: Similar questions

git refname 'origin/master' is ambiguous
Git: refname 'master' is ambiguous
warning: refname 'HEAD' is ambiguous
Git warning: refname 'xxx' is ambiguous

Community
  • 1
  • 1
  • Could you add the output of `git branch -a`? If you're unsure what you're doing with `git`, I'd recommend a read of [the Pro Git book](http://git-scm.com/book), which I found really helpful when learning the theory behind `git`. Has nice diagrams and everything. – simont Dec 17 '12 at 06:19

2 Answers2

8

You've got two branches called upstream/master. One is a local branch, and one is the branch on the remote. When you try to do a git merge, git doesn't know which of these two branches you wish to merge from, hence the ambiguity.

This can be seen from the git branch -a (show all git branches, including remotes):

upstream/master
<SNIP>
remotes/upstream/master

To fix this, you could either rename (or delete) the local branch:

git branch -m <old name> <new name>

In your case, you'd rename something like this (change name to newname):

git branch -m upstream/master newname

This should allow you to do a git fetch / git merge properly.

simont
  • 68,704
  • 18
  • 117
  • 136
  • I renamed upstream/master to upstream/mastertwo, but now when I try to merge from upstream/mastertwo it still says up-to-date. – Asdfsadfasdf Asdfasdf Dec 17 '12 at 06:56
  • You renamed the _local_ branch, which is _probably_ unnecessary and was created just as a result of some mistake in your use of git. You want to merge from the _remote_ branch that should be still named upstream/master. – Michał Politowski Dec 17 '12 at 09:09
2

Either just run:

git merge remotes/upstream/master

instead of

git merge upstream/master

or delete your local upstream/master branch, by running:

git branch -d upstream/master

And learn how git works ;). It’s not that complicated and once you understood the core principles everything is quite easy.

Chronial
  • 66,706
  • 14
  • 93
  • 99