How can I determine which commits were squashed in git?

git, git-rebase, githooks

Solution

Unless that information is still in the reflog of the repo in which you just git squash commits,... I don't think you would be able to get that information back. See "How to undo a git merge squash?".

So your script could work in the local git repo in which a squash took place, but it wouldn't work in a clone of that same repo.

Unless a squash is systematically documented in the comments when a user does one, that information (which commits has been squashed) won't be available.

Problem

I'm writing a script which keeps reference of some commits in a repository, but if some commits gets squashed then references become invalid. I know that there is `pre-rebase` hook, but no `post-rebase` hook, so is there a way to determine which commits get squashed together? For example, before rebase I had this history: ``` 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. ``` After rebase I got: ``` 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. ``` How can I find out that `82ed26a` + `8047297` = `9b7ac26`?

Original source

Related problems