12

For some reasons, I have to rewrite the entire history of my git repository to change the committer_id of every commit. However, I attached a note to more or less every commit and using git-filter-branch to change the committer_id will logically create new commits, leaving the notes behind. Is there a way to copy the notes to their matching new commit?

This thread seems to ask similar questions but was left with no solution in 2011.

Thank you for your help!

Kiplaki
  • 171
  • 6
  • 2
    do you have a list of OLD_SHA->NEW_SHA? Or perhaps since you are only changing GIT_COMMITTER_NAME you can `git rev-list` on the orig refs and the replacement refs and get that? One you have old->new sha mapping the problem should be trivial. – Andrew C Oct 28 '14 at 17:01
  • Good idea, I had not considered it this way. Thanks! – Kiplaki Oct 29 '14 at 09:27

1 Answers1

3

The problem is probably that git-notes need some extra config to work the way you want it to. You probably need this configuration variable

git config notes.rewriteRef refs/notes/commits

From the documentation: https://git-scm.com/docs/git-notes#git-notes-notesrewriteRef:

GIT_NOTES_REWRITE_REF

When rewriting commits, which notes to copy from the original to the rewritten commit. Must be a colon-delimited list of refs or globs.

If not set in the environment, the list of notes to copy depends on the notes.rewrite. and notes.rewriteRef settings.

Basically, Git must have your permission to transfer the notes from the original commits to the new ones that you are rewriting. You could also see this Stackoverflow thread for a longer explanation:

Is there a way to automatically merge notes if commits for those notes get squashed?

Community
  • 1
  • 1
Jesper Rønn-Jensen
  • 106,591
  • 44
  • 118
  • 155