Getting the information of squashed commits in Git Getting the information of squashed commits in Git git git

Getting the information of squashed commits in Git


The point of squashing commits is to rewrite history, replacing the original commits with a single commit.

That said, it's hard to make things actually disappear in git. The easiest way to get at those commits will be via git reflog. Try git reflog <branch> for the previous positions of the branch which you rebased.

You should be able to find the SHA1 of the tip of the branch just before your interactive rebase. (If the branch no longer exists, try git reflog show to see the reflog of HEAD. It should be there too, just more other activity to sort through.)

Once you have the SHA1, you're golden - use git log -p or gitk to view the commits and see their diffs. (If you want to do a lot with it, create a branch there, so you don't have to paste the SHA1 over and over again.)

This will still be possible after running git gc, as long as it hasn't been a long time since you squashed those commits. gc only prunes unreachable dangling objects over a certain age.

Commits are considered reachable if they're reachable from anything in the reflogs, and reflogs take 90 days to expire, so you can generally count on those original commits hanging around for three months.