I've been working on a new feature for my team's project, and my code changes involved many debug print statements on rather useful places. Now before pushing the code, I'll be removing all these debug print statements but I know whenever I come back to this I'll end up putting those debug print statements again.
So if I remove the debug statements, and commit. All the needed debug statements will basically be git diff HEAD^!. Inverse of this diff (if that's even a thing) will be all the debug statements I need whenever in need. Is there a way to do that?
Or would you suggest any other sane workflow to handle this kind of a thing.
If your prtinf statements are easily parsed, you can declare a content filter driver, here a clean filter:

(Source: Pro Git book: Customizing Git - Git Attributes)
Your clean script will be a simple sed command skipping lines matching a pattern.
That way, any git diff or git commit will consider your sources without the printf debug statements.
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