0

So, this has been asked elsewhere, but the answers I see don't seem to work for me.

I have a bare remote repository, "origin". I work locally, in a branch named "ect010", which the remote has as well, and it is tracked:

git remote show origin
* remote origin
  Fetch URL: /projects/ECT/bareChain.git
  Push  URL: /projects/ECT/bareChain.git
  HEAD branch: master
  Remote branches:
    develop tracked
    ect010  tracked
    master  tracked
    oldXML  tracked
  Local branch configured for 'git pull':
    ect010 merges with remote ect010
  Local ref configured for 'git push':
    ect010 pushes to ect010 (local out of date)

The remote ect010 branch has a few more recent commits than my local ect010 (I can see these commit if I go tho the bare directory and do a git log).

Knowing this, I do from my local ect010 branch:

git fetch origin ect010

Which doesn't seem to do much:

From /projects/ECT/bareChain
 * branch            ect010     -> FETCH_HEAD

..and finally, I want to see the differences between my local ect010 and the remote ect010, so I tried

git log origin/ect010

But this shows the same log as my local log, not showing the latest commits that I know are pushed on bare. Why? Obviously I am doing something wrong, but as I see on some other posts, this technique should work.. no?

I'd appreciate any help! Thanks a lot,

Arnaud

EDIT: (because I also see this suggestion in other answers, but seems OK in my config)

Doing

git config --get remote.origin.fetch

Gives:

+refs/heads/*:refs/remotes/origin/*

..which seems OK, right?

Arnaud
  • 445
  • 4
  • 18
  • 1
    You must have a very old version of Git. The default behavior for `git fetch origin ` changed in Git 1.8.2 to update `origin/`. Current Git is 2.26; 1.7 and 1.8 were outdated many years ago. That said, just run `git fetch`, as in the accepted answer. – torek Mar 25 '20 at 16:47
  • True.. I am using 1.7.1 ! Thanks! – Arnaud Mar 26 '20 at 07:43

1 Answers1

5

When you do git fetch origin ect010 it fetches the branch into a special ref called FETCH_HEAD, it does not update the remotes/origin/* branches. And you see it tells you so:

From /projects/ECT/bareChain
 * branch            ect010     -> FETCH_HEAD

Just do git fetch origin so it will do fetches according to +refs/heads/*:refs/remotes/origin/* pattern.

BTW, if you want just to fetch that single branch, you have to specify full names and : for the mapping, according to the pattern above. I.e.

git fetch origin refs/heads/ect010:refs/remotes/origin/ect010

But honestly I don't see any reason why would you ever need this. Just fetch everything.

kan
  • 28,279
  • 7
  • 71
  • 101