Notes, refs, etc. (was: Re: [PATCH v10 1/5] fetch: add remote.<name>.refmap)
- From
D. Ben Knoble <ben.knoble@gmail.com>
- Date
- Nov 7, 2026, 20:20 UTC
- Message-ID
- <CALnO6CB5uqHpeJm9QUC-J7n=RBVB+0pXRuMfaSQZt7mHoZbasg@mail.gmail.com>
- In-Reply-To
- <xmqqmrrwywq8.fsf@gitster.g>
+Cc Kristoffer Haugsbakk as a fellow notes user ;)
On Thu, Oct 29, 2026 at 6:21 PM Junio C Hamano <gitster@pobox.com> wrote:
Show 14 quoted lines
> > Ben Knoble <ben.knoble@gmail.com> writes: > > > Yes, I would love to add pushRefmap atop later! It would > > ease my working with notes, I think. > > > Yes, I would love to add pushRefmap atop later! It would > > ease my working with notes, I think. > > Tell us more when you are off mobile ;-). > > I do not think I planned to add '--refmap' support on the push side, > even from the command line, but I can imagine there would be > reasonable workflows that benefit from having one.
In my local copy of git.git, I want to have both Junio's amlog for spelunking and my own notes for patches. I only want to push out my notes + topics to my remote, though (I work on Git from different machines and it's nice to have the notes sync'd on both). Here's the hack I ended up with, and it has some downsides.
In particular, "git push" in this configuration does too much, so I usually have to think about whether that's ok. A pushRefmap would let me separate what to push by default (push.default!) from how to map pushing when I want to push, say, notes or other things. I have to be especially careful with a "git pf" (push, force-with-lease, force-if-includes), since I usually do *not* want to forcibly overwrite the remote notes---instead I should pull those down and merge them†.
So, here's the relevant config (I have a remote "benknoble" and a remote "origin", among others):
[core]
notesRef = refs/notes/benknoble/commits
[notes]
rewriteRef = refs/notes/benknoble/commits
displayRef = refs/notes/origin/amlog
[remote "origin"]
fetch = +refs/notes/amlog:refs/notes/origin/amlogThe "usual" stuff to make my notes important, but still show amlog notes when browsing history. (The origin remote section is in addition to the normal remote section with it's url and heads->origin/ mapping.)
[remote]
pushDefault = benknoblePush to my remote.
[remote "benknoble"]
fetch = refs/notes/*:refs/notes/benknoble/*
push = refs/heads/*:refs/heads/*
push = refs/notes/benknoble/*:refs/notes/*
push = ^refs/notes/origin/amlogIn addition to the usual config added by "git remote add", fetch remote notes into a local hierarchy, and push them out, but ignore amlog, and don't forget to also be able to push heads. Without the heads map, "git push" will not push branches!
Now, maybe I'm holding something in a way it wasn't intended and that's made my life harder, I dunno.
†: There isn't a great story for that, either :/ When "git fetch" fails to fetch notes because of divergence with local, I end up saying
git fetch benknoble refs/notes/commits
git range-diff refs/notes/benknoble/commits...FETCH_HEAD
git notes merge FETCH_HEADor something.
It's *almost* like we need remote-tracking branches for notes, ahaha… at that point, Scott's git-meta work becomes possibly more appealing to me, even if a part of me wants to "fix" notes so everyone can use them easily.
-- D. Ben Knoble