How to view whitespace issues?
git config --global core.whitespace OPTIONS
Git comes with a built in whitespace issue detector, which can detect 6 common whitespace issues, which are:
blank-at-eollooks for spaces at the end of a line. This option is enabled by default.
blank-at-eofnotices blank lines at the end of a file. This option is enabled by default.
space-before-tablooks for spaces before tabs at the beginning of a line. This option is enabled by default.
indent-with-non-tablooks for lines that begin with spaces instead of tabs. This option is disabled by default.
tab-in-indentwatches for tabs in the indentation portion of a line. This option is disabled by default.
cr-at-eoltells Git that carriage returns at the end of lines are OK. This option is disabled by default.
You can set the selected options with
git config --global core.whitespace option1,option2 and disable an option by prepending a
- in front of it, or use the default value by leaving it out of the setting string entirely.
Once the whitespace options are set,
git diff will detect and color them.
git config --global core.whitespace trailing-space,-space-before-tab,indent-with-non-tab,cr-at-eol
diff --git a/articles_controller.rb b/articles_controller.rb
index ea67e94..99f04b3 100644
@@ -4,7 +4,7 @@ class ArticlesController < ApplicationController
- @article = Article.find(params[:id])
+ @article = Article.find(params[:id])
See git config to learn more about it.