7

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 [email protected]:example (fetch) origin [email protected]: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.

3 Answers 3

11

Have you tried git remote update? This will update all remotes, creating remote-tracking branches as needed.

Sign up to request clarification or add additional context in comments.

1 Comment

Just tried it, exactly the same result as git fetch -a origin, unfortunately.
10

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.

1 Comment

Thanks. For me, my fetch line existed, but was only fetching from a particular release branch for some reason. I updated the line to the above and did git remote update and then git reset --hard origin/branchname and everything works perfectly.
0

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..

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.