Whenever I start a new project, I like to check in configurations to Git, so that every other developer uses the same settings as I do. This also leads to more reproducible build.
This post summarizes the different files and their interdependencies. For me it provides a copy-and-paste resource for my projects. For you it might be a starting point for you own project.
The setup is opinionated, your mileage may vary. The projects I work in often look like this:
- Development is a mixed Windows, Linux and MacOS environment
- Sometimes a virtual machine running Linux (Vagrant/Virtual Box) mounts the files using a shared folder from a Windows host
- Build automation runs on Linux, usually with Jenkins
- My IDE is IntelliJ
The EditorConfig is a file called .editorconfig in the root of the project. You can specify how your editor should handle your files. IntelliJ has built-in support for this configuration files.
This file is called .gitattributes and resides in the root folder of your project. This tells Git how to treat line endings and binary files.
The line ending settings need to match your Editorconfig.
Note that changing these settings doesn’t affect your working directory. You’ll need to perform a reset on a clean working tree as the following command will discard any uncommitted changes. See "How to normalize working tree line endings in Git?" on StackOverflow.
git rm --cached -r . git reset --hard
This file is called .gitignore and resides in the root folder of your project. Subfolders can have additional .gitignore files that can extend and override these settings.
The files to ignore depend on the IDE build tools you use. Here the most common I use.
For more information about the required plugins feature in IntelliJ, visit the section “Required Plugins” in the chapter “Manage plugins” in the IntelliJ online help.
The most important bit is to match the file encoding that is also used in .editorconfig.
<project> <properties> <encoding>UTF-8</encoding> <!-- ... --> </properties> <!-- ... --> </project>
I hope this will help you in new and existing projects like it helps me.
I’m looking forward to your feedback - contact me!