git 日志消息中提到的 rebase 和 SHA
git rebase and SHAs mentioned in log messages
有时 git 提交的日志消息会提到其他提交的 SHA。这发生在 git revert
的建议日志消息中,您也可以手动添加它 ('fixed bug introduced in abcd0123')。
变基时,提交的 SHA 会发生变化。有没有一种方法可以自动修复日志消息以获得新的 SHA?通常,在 100% 的情况下这可能是不可能的(提交可能会完全消失、被压缩等)。但是在 90% 的情况下,一个简单的 rebase 会在原始提交和 rebased 提交之间留下一对一的对应关系,因此应该可以在日志消息中重新映射 SHA。
我试过git rebase --verbose
,我希望它能打印类似
的东西
Applying: My log message here.
old commit was 01234
new commit is abcde
然后我可以使用它来手动 fiddle 日志消息(进一步变基...这将反过来更改 SHA...所以这会很尴尬,但仍然有可能)。但据我所知 --verbose
不会打印比正常模式更多的信息。
有什么神奇的工具可以为我变基和重写日志消息吗?在没有小马的情况下,我能否说服 git rebase
打印更多有关新旧 SHA 的信息,以便我自己完成这项工作?
Sometimes the log message for a git commit will mention the SHA of other commits[...]When rebasing, the SHAs of commits change. Is there a way I can automatically fix up the log messages to have the new SHAs?
您可以使用 git patch-id
来查找应用相同更改的提交,最暴力的方法是
git rev-list --no-merges --reflog --all \
| git diff-tree --stdin -p \
| git patch-id | sort > patch-ids
awk '{print ,}' patch-ids | uniq -Df1
在您的存储库中找到应用类似补丁的每一组提交。对结果应用一点 git log --grep=
,也许对你的 rev-list args 有一些限制,应该会让你到达你想去的地方。
在 GNU/anything 将 uniq 替换为
uniq -f1 --all-repeated=separate | awk '{print }' | awk '{=; print}' RS=
为您分组提交 ID。您可以使用 join
或更多 awking 在其他地方实现相同的效果。
您可以将 git notes 添加到提交(或任何对象),如果您尝试分发有关发生的事情的警告,这可能会有所帮助。
有时 git 提交的日志消息会提到其他提交的 SHA。这发生在 git revert
的建议日志消息中,您也可以手动添加它 ('fixed bug introduced in abcd0123')。
变基时,提交的 SHA 会发生变化。有没有一种方法可以自动修复日志消息以获得新的 SHA?通常,在 100% 的情况下这可能是不可能的(提交可能会完全消失、被压缩等)。但是在 90% 的情况下,一个简单的 rebase 会在原始提交和 rebased 提交之间留下一对一的对应关系,因此应该可以在日志消息中重新映射 SHA。
我试过git rebase --verbose
,我希望它能打印类似
Applying: My log message here.
old commit was 01234
new commit is abcde
然后我可以使用它来手动 fiddle 日志消息(进一步变基...这将反过来更改 SHA...所以这会很尴尬,但仍然有可能)。但据我所知 --verbose
不会打印比正常模式更多的信息。
有什么神奇的工具可以为我变基和重写日志消息吗?在没有小马的情况下,我能否说服 git rebase
打印更多有关新旧 SHA 的信息,以便我自己完成这项工作?
Sometimes the log message for a git commit will mention the SHA of other commits[...]When rebasing, the SHAs of commits change. Is there a way I can automatically fix up the log messages to have the new SHAs?
您可以使用 git patch-id
来查找应用相同更改的提交,最暴力的方法是
git rev-list --no-merges --reflog --all \
| git diff-tree --stdin -p \
| git patch-id | sort > patch-ids
awk '{print ,}' patch-ids | uniq -Df1
在您的存储库中找到应用类似补丁的每一组提交。对结果应用一点 git log --grep=
,也许对你的 rev-list args 有一些限制,应该会让你到达你想去的地方。
在 GNU/anything 将 uniq 替换为
uniq -f1 --all-repeated=separate | awk '{print }' | awk '{=; print}' RS=
为您分组提交 ID。您可以使用 join
或更多 awking 在其他地方实现相同的效果。
您可以将 git notes 添加到提交(或任何对象),如果您尝试分发有关发生的事情的警告,这可能会有所帮助。