I need to remove all trailing whitespaces before changed files will be committed. The question is how to do it?
I need to remove all trailing whitespaces before changed files will be committed. The
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I don’t believe there’s a good way to just automatically remove trailing whitespace at commit time (and I don’t believe it’d be a good idea to do it if you could).
I’ve used a hook before to reject commits that add trailing whitespace, which worked well for me; create/add the following to
.git/hooks/pre-commitand make it executable: