tusharmath
tusharmath

Reputation: 10992

ignore unnecessary new-line changes from git

Is there a way I can ignore all new line updates from a git commit?

I have a tool which unnecessarily removes new-lines from my files and after running it I have like hundreds of files changed which essentially only have new lines removed from them. I want to ignore such changes.

Upvotes: 1

Views: 1753

Answers (2)

modmoto
modmoto

Reputation: 3290

As far as I understand this article you can only ignore it while making a diff but not for commiting. That would also not make a lot of sense, because what will be stored in the repo and what would happen if you made a pull afterwards?

What I like to do is making a pure cleanup commit, so the changes you really do to the code are separated.

For the diff it would be something like

git diff --ignore-space-at-eol -b -w --ignore-blank-lines [commit] ...

Upvotes: 2

infamoustrey
infamoustrey

Reputation: 718

It looks like you may not need a script at git already has some functionality for this built in when using a .gitattributes file

Check out this GitHub Article on dealing with line endings

text eol=crlf - Git will always convert line endings to CRLF on checkout. You should use this for files that must keep CRLF endings, even on OSX or Linux.

text eol=lf - Git will always convert line endings to LF on checkout. You should use this for files that must keep LF endings, even on Windows.

Upvotes: 0

Related Questions