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-eol
looks for spaces at the end of a line. This option is enabled by default.blank-at-eof
notices blank lines at the end of a file. This option is enabled by default.space-before-tab
looks for spaces before tabs at the beginning of a line. This option is enabled by default.indent-with-non-tab
looks for lines that begin with spaces instead of tabs. This option is disabled by default.tab-in-indent
watches for tabs in the indentation portion of a line. This option is disabled by default.cr-at-eol
tells 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
git diff
diff --git a/articles_controller.rb b/articles_controller.rb
index ea67e94..99f04b3 100644
--- a/articles_controller.rb
+++ b/articles_controller.rb
@@ -4,7 +4,7 @@ class ArticlesController < ApplicationController
end
def show
- @article = Article.find(params[:id])
+ @article = Article.find(params[:id])
end
def new
See git config to learn more about it.