Re: Notes, refs, etc. (was: Re: [PATCH v10 1/5] fetch: add remote.<name>.refmap)
- From
- Kristoffer Haugsbakk <kristofferhaugsbakk@fastmail.com>
- Date
- Nov 20, 2026, 14:24 UTC
- Message-ID
- <f0dd8e55-5165-4a28-a623-748bf6c86d76@app.fastmail.com>
- In-Reply-To
- <CALnO6CB5uqHpeJm9QUC-J7n=RBVB+0pXRuMfaSQZt7mHoZbasg@mail.gmail.com>
On Sat, Nov 7, 2026, at 21:20, D. Ben Knoble wrote:
Show 40 quoted lines
>[snip] >> 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/amlog
I don’t use multiple computers right now. But I do have both private and public Git notes. In the work repository I have this
[remote "o"]
[...]
# NOTE “tracking” idea came from the Git mailing list
# NOTE We cannot use a negative refspec to exclude branch things here
# (what I wanted) because neg. refspecs cannot have
# the destination part
fetch = +refs/*:refs/tracking/o/refs/*This is from some email thread(s) about using a namespace for tracking all remote refs instead of just branches. Now I have the state of the remote notes in case there is a divergence.
(Realistically this would only check my own mistakes since no one else seems to use these Notes.)
There’s even a comment there about negative refspecs. I think something like that got mentioned here in this thread or some months ago? I didn’t have the opportunity to engage then.
Show 24 quoted lines
> > The "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 = benknoble > > Push 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/amlog > > In 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.
I haven’t tried the above but it doesn’t look like you have made it harder for yourself than you need to, considering your needs. ;)
Show 14 quoted lines
> > †: 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_HEAD > > or 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.
I don’t know what git-meta is. But in any case, I haven’t seen a forcing-use case for making Notes simpler to use. Right now they are okay-enough for the simple needs that I have seen, which is single-author (program or person) or automatic-merge (git-appraise(1) uses json-lines so that cat-sort-uniq merge strategy works).
But imagine some kind of collaborative Notes usage, like multiple people posting commentaries on commits. In that case one would need better tooling, for sure. But collaborative metadata on commits is a bit like the ideas like “history of history”.[1] It’s probably not going to happen.
[1] https://lwn.net/Articles/914041/