diff --git a/.gitattributes b/.gitattributes
new file mode 100644
index 0000000..4e5229f
--- /dev/null
+++ b/.gitattributes
@@ -0,0 +1,16 @@
+*		whitespace=space-before-tab,trailing-space
+*.[ch]		whitespace=space-before-tab,trailing-space,indent-with-non-tab,tabwidth=4
+*.cpp		whitespace=space-before-tab,trailing-space,indent-with-non-tab,tabwidth=4
+*.po		whitespace=space-before-tab,trailing-space,tab-in-indent,-blank-at-eof
+*.html		whitespace=space-before-tab,trailing-space,tab-in-indent,-blank-at-eol
+*.ps1		whitespace=space-before-tab,trailing-space,indent-with-non-tab
+*.bat		whitespace=space-before-tab,trailing-space,indent-with-non-tab
+*.mak		whitespace=space-before-tab,trailing-space,indent-with-non-tab
+
+# Avoid confusing ASCII underlines with leftover merge conflict markers
+README		conflict-marker-size=32
+README.*	conflict-marker-size=32
+*.txt		conflict-marker-size=32
+
+# Test output files that contain extra whitespace
+*.out		-whitespace
