Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

enter image description here

There is a red bar after + sign. What is this ?

like image 491
Rahul Kumar Avatar asked Jan 02 '16 20:01

Rahul Kumar


People also ask

What does red mean in git diff?

Diff colors should show green for insert, red for delete · Issue #5430 · facebook/jest · GitHub.

What does green and red mean in GitHub?

Green if clean, red if dirty. GitHub.

What do the numbers in git diff mean?

Let's analyze a simple example -1,6 means that this piece of the first file starts at line 1 and shows a total of 6 lines. Therefore it shows lines 1 to 6. 1 2 3 4 5 6. - means "old", as we usually invoke it as diff -u old new . +1,4 means that this piece of the second file starts at line 1 and shows a total of 4 lines ...


2 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 might contain tab-in-indent, space-before-tab, or indent-with-non-tab. You should change it to suit your preferences if this isn’t really a mistake.

like image 187
Ry- Avatar answered Oct 01 '22 11:10

Ry-


Here are the possible values for the core.whitespace.
Your configuration value will be one of the tabs value below

core.whitespace

A comma separated list of common whitespace problems to notice.
git diff will use color.diff.whitespace to highlight them, and git apply
--whitespace=error will consider them as errors.
You can prefix - to disable any of them (e.g. -trailing-space):

  • blank-at-eol

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

  • space-before-tab###

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

  • indent-with-non-tab

    treats a line that is indented with space characters instead of the equivalent tabs as an error (not enabled by default).

  • tab-in-indent

    treats a tab character in the initial indent part of the line as an error (not enabled by default).

  • blank-at-eof

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

  • trailing-space

    a short-hand to cover both blank-at-eol and blank-at-eof.

  • cr-at-eol

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

  • tabwidth=n

    tells how many character positions a tab occupies; this is relevant for indent-with-non-tab and when Git fixes tab-in-indent errors. The default tab width is 8. Allowed values are 1 to 63.


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

like image 38
CodeWizard Avatar answered Oct 01 '22 13:10

CodeWizard