This gist shows how you can linearize complex Git tree that has many merge commits, making it like a "squash on merge" policy was used from the beginning of repo's history, while modifying commits' authorship in a standardised way.
It checks if a commit is a merge commit and, if so, modifies its author and parents:
- merge commit becomes "regular" commit with only 1 parent
- authorship for ex-merge commit is taken from the last commit of merged branch (2nd parent that is discarded). It assumes that single person was working on a branch, so it may produce false blame information if multiple people authored commits in a branch (all changes from the branch have authorship from last commit's author). In our case it was needed because merge commits are automated and authorship comes from bot user, so without