Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Preserve git notes when rewriting history with git filter branch

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!

like image 535
Kiplaki Avatar asked Oct 28 '14 15:10

Kiplaki


1 Answers

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?

like image 153
Jesper Rønn-Jensen Avatar answered Oct 17 '22 07:10

Jesper Rønn-Jensen