git - 使用 git filter branch 重写历史时保留 git 注释

标签 git git-filter-branch git-notes

出于某些原因,我必须重写我的 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/

相关文章:

bash - 如何在文件夹模式上使用 git filter-branch

Git - 使用过滤器分支删除具有空变更集的提交

git - 我们如何排除 `Notes added by ' git Notes 添加 '` from ` git log`?

git - 如何在git中完全删除一个头部分离的分支?

git 逐 block merge

git - 恢复到 Bitbucket 中的旧提交

git filter-branch 只改变受影响的提交

git - 如何获取给定目录名称的树哈希?

git - 在 git 中获取时缺少引用/注释

git - 预期的提交者名称 Git 推送问题