When working with code (mostly c++ in my case) and specifically with git and gitlab, I often find myself working on a specific merge request and feature addition for several weeks. At the end, I arrive with a very long merge request that is very hard for the maintainers to understand, because I have committed a lot of changes.
Some of these changes are intentional and important to the feature at hand, others are trivial like fixing the indentation of a certain section of code, which I often to to improve readability while I'm debugging. However, in order for the MR to be as small as readable as possible, I'd like to "undo" all the trivial changes not affecting the code itself (but only the layout) before removing the WIP label from my MR. So I sometimes find myself going through my MR and undoing all those prettifications by hand in order to make the MR more readable for the reviewers.
This is a lot of stupid work that could be spent better elswhere.
Is there a script or mechanism that I can use (specifically on c++ code) to go through the code and undo all trivial changes (for example, whitespace changes) with respect to a certain commit? This would simplify my life significantly. I could see myself writing a script for this, but I'm hoping for there to be some git magic that I can use, or for someone else already having solved this issue for me. Any suggestions?