News for hackers. Stuff that matters.
Re:Git Notes: Git's coolest, most unloved­ feature (2022) by xg15 on Sunday June 22, 2025 @03:16PM (#44349501)
Sounds really cool, but how do notes play together with the "history rewriting" features (amend, rebase, etc) where you effectively replace a commit with a modified copy? It sounds as if the notes are attached to a specific commit (or tree or blob) ID. Are git rebase etc smart enough to also copy over the notes to the new commit, or will they just vanish?

What happens on interactive rebases, e.g. if I squash multiple commits into a single one?

I see the same problem with attaching notes to blobs and trees: It's not doing what you might think it does: It feels like it would attach metadata to a file or directory in the repo, but it really attaches the metadata to some specific content:

E.g. if you have a blob that encodes the string "Hello world!" and attach the note to it, would git associate that note with all files that have that content?

Also, if you change one file to "Hello, world!", would it lose the notes?

Re:Git Notes: Git's coolest, most unloved­ feature (2022) by rlpb on Sunday June 22, 2025 @03:31PM (#44349606)
> Are git rebase etc smart enough to also copy over the notes to the new commit...

This is configurable. By default, amend and rebase operations will copy them forward. See git-config(1) under `notes.rewrite`.

Re:Git Notes: Git's coolest, most unloved­ feature (2022) by xg15 on Sunday June 22, 2025 @04:20PM (#44349952)
Ah, ok. That sounds better. Thanks for the info!
Re:Git Notes: Git's coolest, most unloved­ feature (2022) by chrishill89 on Monday June 23, 2025 @11:31AM (#44356810)
By default no copying will be done. While `notes.rewrite.amend` and `notes.rewrite.rebase` are true you also need `notes.rewriteRef` which tells it what notes refs should be rewritten. And it has no value by default. (you can set it to a glob copy over all notes refs)
Re:Git Notes: Git's coolest, most unloved­ feature (2022) by fnl on Wednesday June 25, 2025 @04:30PM (#44381544)
Thanks for the warning! From the git docs:

> Set it to refs/notes/commits to enable rewriting for the default commit notes.

Why wouldn’t that at least be the default? Why is rewriting off by default in the first place?