I've always been sceptical about 'squashing' or rewriting history, and now I'm just about convinced that I should ban this practice from the repos I manage. But maybe somebody can answer this, and save the day for my squash-championing colleagues.
I just came across a line of code that I want to understand the reasoning behind, so I used git annotate
to find out who wrote it and why. But it points to a 'squashed' commit, a long list of commit message headers about a myriad of features and bug-fixes, without detail. Not really helpful.
'Oh, but there's always the reflog,' I've been assured; 'information never actually gets lost in git!' Okay, glad to hear it! But I tried git reflog <squashed-commit-hash>
, and got no output at all—not helpful. I also tried git rev-list <squashed-commit-hash>
, and got a list of hundreds of hashes, and after manually inspecting a few of them with git show
, I've concluded they're not parts of what got squashed—also not helpful.
So is it actually possible to find out which single commit contributed to that line of code, and see that commit's entire message? Can it be done in a single git command, without having to be a bash guru? Or has this information, in fact, actually been lost in git after all?