Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Workaround for git whitespace commits: Commit only 'REAL' changes

Tags:

git

git-commit

Recently I started as a developer in a new company. Most of them aren't used to use shortcuts to 'Format code'. My fingers are practically doing ALT+SHIFT+F after every line of code, as I have been using Netbeans for like 6 years now. But now I have to develop .NET so I use VS2012 and bind the shortcut for command Edit.FormatDocument to ALT+SHIFT+F, and I'm still spamming it :).

The only thing is that my colleagues aren't really fond of this Edit.FormatDocument, and they do everything by hand. So every commit now, from my side, is full of whitespace changes... :/ Changes in indentation style (tabs vs. spaces) are especially dramatic.

Yes, I've seen some examples here and here, but they aren't that easy... and they are probably outdated. Isn't there any feature inside Git that can help me out?

Is it possible to turn a config item on, to ignore whitespace when committing in Git?

like image 660
Highmastdon Avatar asked Nov 24 '25 18:11

Highmastdon


1 Answers

If in your files the whitespace isn't significant you can instruct git to ignore some warnings with:

git config --global apply.whitespace nowarn
like image 121
Atropo Avatar answered Nov 27 '25 13:11

Atropo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!