I would like to write a git hook that automatically does some code cleaning, such as removing trailing spaces. It is easy to write a script to reject some commits, but I would rather just fix the problems transparently when possible. Although I understand that git has built-in support for such things (automatic translation of translation strings, etc.), But I would like something more flexible. Is it possible to do this with a pre-commit hook? Can you change the index directly (or is there a better way to do this)?
I also understand that in the end I will need a server hook that rejects bad commits for developers who do not use a local hook, but I would like to help those who prefer to use it. (If you can change the code on the server, that would be even better, but I don't think you can.)
source
share