These differences usually have at least one of the following reasons:
Source encoding
Java does not have an encoding defined in the source file, so you have to agree with your team members. Usually there's no good reason to choose anything else than UTF-8. If your preferred editor only supports system encoding... choose another one.
Line endings
Git supports a local configuration of LF handling by setting the core.autocrlf
config. I strongy recommend not to use it. Make a project wide configuration and place a .gitattributes
file in your project root, for example:
# Set the default behavior, in case people don't have core.autocrlf set.
* text=auto
# Explicitly declare text files you want to always be normalized and converted
# to native line endings on checkout.
*.java text
# Declare files that will always have Unix LF line endings on checkout.
*.sh text eol=lf
Dockerfile text eol=lf
Indentation
A mixture of tabs an whitespaces can really mess up your commit history. Many IDEs do an automatic formatting or pretty printing on every save action, but they all do it slightly different. Agree with your team members on a common source formatting (and be prepared for longer discussions).
If you cannot even agree on tabs or spaces, here's a good argument:
Developers Who Use Spaces Make More Money Than Those Who Use Tabs