我正在编写一个脚本,用于在存储库中保留对某些提交的引用,但如果某些提交被压缩,则引用将变得无效。我知道有 pre-rebase
Hook ,但没有 post-rebase
Hook ,那么有没有办法确定哪些提交被压缩在一起?
例如,在 rebase 之前我有这样的历史:
cf79121 Refactor the trim_file_name method. Closes #1965.
82ed26a Updated dependencies and project versions.
8047297 Updated Node.js implementation package information.
b2b727c Added "finished" callback, which is called for each "completed" or "failed" event.
rebase 后我得到:
cf79121 Refactor the trim_file_name method. Closes #1965.
9b7ac26 Updated dependencies, project versions, and node.js package information.
b2b727c Added "finished" callback, which is called for each "completed" or "failed" event.
我怎样才能知道 82ed26a
+ 8047297
= 9b7ac26
?
最佳答案
除非该信息仍在您 只是 git squash 提交的 repo 的 reflog 中,否则...我认为您无法取回该信息。
参见“How to undo a git merge squash?”。
因此您的脚本可以在发生挤压的本地 git 存储库中工作,但它不能在同一存储库的克隆中工作。
除非在用户执行压缩时在评论中系统地记录压缩,否则该信息(提交已被压缩)将不可用。
关于git - 我如何确定哪些提交在 git 中被压缩了?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14517265/