In a repository there are a very large number of commits caused by automated build-tool updates to AssemblyInfo files (the project is in C#). These commits all have "Dev BuildAgent" as an author.
Is there any way to squash all commits in a repository from a specific author into the first child from another author?
Of course, one possibility would be to run git rebase --interactive
using the SHA of the root commit and manually go through the list of commits and apply the squash command to the appropriate commit manually. However, it would be useful to know whether there is a quicker option, bearing in mind there are a very large number of commits.
To squash all commits of the author with email [email protected]
into the next child commit of another author, you can use the following. You can of course also check any other attribute like author name, commiter email, committer name, ...
git filter-branch --commit-filter '[ "$GIT_AUTHOR_EMAIL" = "[email protected]" ] && skip_commit "$@" || git commit-tree "$@"'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With