Git doesn't seem to want to keep local refs to origin/master

git

Solution

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 `git clone`.

See the git pro book for a good description of what's going on.

Problem

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' ``` Hm. ``` $ git remote -v origin git@example.com:example (fetch) origin git@example.com:example (push) ``` okay, that looks right. ``` $ git branch -a ... # nothing from origin ``` Hm. ``` $ 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'. ``` Wha? ``` $ 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.

Original source