What is the meaning of these red bars in the difference of git files

enter image description here

A red bar will appear after the + sign. What is it?

+6
source share
3 answers

Potentially bad indentation. You may have used tabs when you configured Git to prefer spaces, or vice versa.

Check git config core.whitespace ; it may contain tab-in-indent , space-before-tab or indent-with-non-tab . You should change it according to your preferences, if this is really not a mistake.

+6
source

The possible values ​​for core.whitespace .
Your configuration value will be one of the tab values ​​below

core.whitespace

A list of common spaces separated by commas is marked.
git diff will use color.diff.whitespace to highlight them, and git apply --whitespace=error will treat them as errors.
You can use the prefix - to disable any of them (for example, -trailing-space):

  • blanks on-eol

    treats trailing spaces at the end of a line as an error (enabled by default).

  • space-before tab ###

    treats the space character that appears immediately before the tab character in the initial part of the line indentation as an error (enabled by default).

  • Indent-with-not-tabs

    treats the indented line with space characters instead of equivalent tabs as an error (it does not turn on by default).

  • indent tab

    treats the tab character at the beginning of the line indent as an error (not enabled by default).

  • WF blanks

    processes empty lines added at the end of the file as an error (enabled by default).

  • trailing space

    short arm to cover both blank-at-eol and blank-at-eof .

  • cr-on-eol

    processes the carriage return at the end of the line as part of the line terminator, i.e. with it, the trailing space does not start if the character before such a carriage return is not a space (not enabled by default).

  • tabwidth = n

    indicates how many character positions a tab occupies; this matters for indent-with-non-tab and when git fixes insert errors. The default tab width is 8. Allowed values ​​are from 1 to 63.


Sample for output when tabs are used as configuration value: enter image description here

+3
source

This means that you have extra spaces in your sources. You must remove this unwanted space.

0
source

All Articles