出于某些原因,我必须重写我的 git 存储库的整个历史记录,以更改每次提交的 committer_id。但是,我或多或少地在每个提交上附加了一个注释,并且使用 git-filter-branch 更改 committer_id 将在逻辑上创建新的提交,留下注释。 有没有办法将注释复制到它们匹配的新提交中?
这thread似乎问了类似的问题,但在 2011 年没有解决。
感谢您的帮助!
最佳答案
问题可能是 git-notes 需要一些额外的配置才能按照您希望的方式工作。您可能需要这个配置变量
git config notes.rewriteRef refs/notes/commits
来自文档: 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.
基本上,Git 必须获得您的许可才能将注释从原始提交转移到您正在重写的新提交。您还可以查看此 Stackoverflow 线程以获得更长的解释:
Is there a way to automatically merge notes if commits for those notes get squashed?
关于git - 使用 git filter branch 重写历史时保留 git 注释,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26612310/