Alex Bollbach
Alex Bollbach

Reputation: 4570

Commits to GitHub repo showing large quantities of unintentional changes

I've been commiting/pushing to a public repo and finding that one commit where I may have changed less than 100 lines results in a commit with 1000 changes.

For example, I may change several lines in a method in AppDelegate.
The resulting problem is something that looks like that following:

To better showoff what whitespace issues might be occurring here is another area of unwanted commitage:

enter image description here

Upvotes: 1

Views: 269

Answers (1)

CodeWizard
CodeWizard

Reputation: 142184

You have formatted the code and now git treats your whitecaps as changes.

Set this flag to ignore any white spaces changes

core.whitespace

Git comes preset to detect and fix some whitespace issues.
It can look for six primary whitespace issues – three are enabled by default and can be turned off, and three are disabled by default but can be activated.

git config --global core.whitespace <...>

core.whitespace

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 is 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=
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

Upvotes: 4

Related Questions