First: apologies for the question title, I don't actually know what the problem is so I don't know how to ask about it.
I want to diff my master with upstream master (should be origin/master, based on the way my remotes are set up).
But: origin was put there after I had been working on it locally for a while, so it's "origin" in name only. That is: I had a local repo, put it up into a gitolite setup, and then told my local git to call it origin.
These are the symptoms:
$ git diff master orgin/master fatal: ambiguous argument 'orgin/master': unknown revision or path not in the working tree. $ git diff master origin/master -- fatal: bad revision 'origin/master'
$ git remote -v origin firstname.lastname@example.org:example (fetch) origin email@example.com:example (push)
okay, that looks right.
$ git branch -a ... # nothing from origin
$ git fetch -a origin From example.com:example * branch HEAD -> FETCH_HEAD
I have no idea if that's correct. It looks productive, but
git diff master origin/master still fails, and:
$ git branch --track omaster origin/master fatal: Not a valid object name: 'origin/master'.
$ ls .git/refs/remotes gitps ps
That looks wrong: those are old remotes that haven't existed for months. Also they're empty. And
.git/remotes doesn't exist at all, although I'm not sure that it should.
You may need to tell git which branches to fetch from origin. In the
.git/config file for this repo, under the
[remote "origin"] section, there should be a line like
fetch = .... This tells git what to fetch and where to put it locally. Here's a pretty standard example:
[remote "origin"] fetch = +refs/heads/*:refs/remotes/origin/* url = ssh://...
If you don't see the
fetch = ... line, you can safely add it to match the example, which is the standard "track all branches and call them origin/branch locally" option set up by
See the git pro book for a good description of what's going on.
git remote updateand then
git reset --hard origin/branchnameand everything works perfectly - Phil 2016-10-12 11:21
Have you tried
git remote update? This will update all remotes, creating remote-tracking branches as needed.
git fetch -a origin, unfortunately - quodlibetor 2012-04-03 21:34
I had a similar issue just now. I discovered that my local .git directory as actually a file
$ file .git .git: ASCII text
I deleted the file, and initialized the git repository
git init && git remote add origin "gitrepo"
Not too sure why this happened. Hopefully this can help someone..