git - 我如何确定哪些提交在 git 中被压缩了?

标签 git git-rebase githooks

我正在编写一个脚本,用于在存储库中保留对某些提交的引用,但如果某些提交被压缩,则引用将变得无效。我知道有 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/

相关文章:

git - 如何传递文件名参数 gitconfig diff textconv?

git - 我如何 git rebase 第一次提交?

git rebase merge 冲突

git - git中预推和预接收钩子(Hook)的区别?

Git 远程/共享预提交 Hook

python - 是否可以从 python 中的 tar 包中提取单个文件

git - 在 GIT 中创建新分支并继承代码更改

git - 使用 Git Kraken 时如何移动存储库?

git - 列出压缩的提交

git - 避免使用 git-multimail 的任何 emailPrefix