3

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?

Community
  • 1
  • 1
Highmastdon
  • 6,960
  • 7
  • 40
  • 68

2 Answers2

2

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

git config --global apply.whitespace nowarn
Atropo
  • 12,231
  • 6
  • 49
  • 62
0

Why don't you change the auto-format settings to match those used by the other developers? If it looks exactly the same, I don't see why it would hurt you. VS allows you to "replace tabs with spaces" as well as specify tab width.

Dan Bechard
  • 5,104
  • 3
  • 34
  • 51
  • I know, that would be a nice solution, but it's too much to change every single config item related to whitespacing, on other workstations, to make it work. If there would be a simple import-config for it I might do that. Also I don't want to overwrite other config settings which are personal to the other programmers. – Highmastdon Jan 14 '14 at 20:18
  • Well, there is an import config option, but I'm not sure about partial imports. You could add it to your default workstation install image so that it's at least resolved for future setups. I'm sure there's some way to programmatically change one or two VS settings without hurting the others. – Dan Bechard Jan 14 '14 at 23:57
  • @Highmastdon he's not saying to change everyone else's whitespace settings, he's saying to change yours! Whatever style everyone else uses, configure your editor to use it also. If the style is totally inconsistent company-wide then you can't really do this, but that's a whole different problem. – amalloy Aug 14 '14 at 18:51