Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Missing refs/notes when fetching in git

Tags:

git

git-notes

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?

like image 564
loeschg Avatar asked Aug 01 '26 15:08

loeschg


1 Answers

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

like image 194
torek Avatar answered Aug 04 '26 07:08

torek



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!