In git, how can I remove Windows line endings from changed lines only?

Viewed 1270

Sometimes when I'm trying to contribute code to an open source project, the project has not been formatted and contains both UNIX and Window line endings. My "smart" IDE will somehow detect which type of ending to use for each file, and if it detects Windows line endings, then all my changes will have Windows line endings (shown as ^M in git diff). How can I remove these Windows line endings from only my changed lines and not the whole file?

1 Answers
Related