2

I have a situation where I'm attempting to fetch remote git notes using the following:

git fetch origin refs/notes/*:refs/notes/*

On a brand new clone of the repository, this works correctly. It pulls down 2 note namespaces:

> git fetch origin refs/notes/"*":refs/notes/"*"                                                                                                                    <system> <dev>
From ssh://url/android-client
 * [new ref]         refs/notes/git-ratchet-1-3.2 -> refs/notes/git-ratchet-1-test
 * [new ref]         refs/notes/git-ratchet-1-dev -> refs/notes/git-ratchet-1-test2

However in my current project repository, when I do that fetch, I only get one of the refs. If I manually remove the file in .git/refs/notes/git-ratchet-1-test and try fetching again, I pull down that file/ref.

Why am I not pulling down the other /refs/notes/git-ratchet-1-test2?

loeschg
  • 29,961
  • 26
  • 97
  • 150

1 Answers1

2

The key to this is here:

If I manually remove the file in .git/refs/notes/git-ratchet-1-test and try fetching again ...

You're manually supplying a refspec, refs/notes/*:refs/notes/*. This is a "non-force" refspec, meaning: "if I already have a ref, don't update mine, keep my existing ref".

To make this an update-forcing refspec, add a + in front.

If you would always like the notes to be fetched (forcing or not), update your git config for that remote to add that refspec to the fetch set. For instance, instead of:

[remote "origin"]
    url = git://git.kernel.org/pub/scm/git/git.git
    fetch = +refs/heads/*:refs/remotes/origin/*

you might make this read:

[remote "origin"]
    url = git://git.kernel.org/pub/scm/git/git.git
    fetch = +refs/heads/*:refs/remotes/origin/*
    fetch = +refs/notes/*:refs/notes/*

(you may have as many fetch = lines as you like, per-remote).

torek
  • 448,244
  • 59
  • 642
  • 775
  • The logic makes sense, though I'm still not seeing the missing notes after doing a `git fetch origin +refs/notes/*:refs/notes/*`. Am I missing a step? – loeschg Oct 08 '15 at 20:46
  • Don't think you're missing anything, as long as you make sure that your shell doesn't eat the `*`s (quote them somehow if needed). – torek Oct 09 '15 at 00:03