git - trim whitespace

前端 未结 4 734
南方客
南方客 2021-02-02 12:51

I\'ve accidentally put some whitespace in my initial commit - it shows up red in git diff --color. What\'s the best way to get rid of the existing whitespace and ho

4条回答
  •  广开言路
    2021-02-02 13:22

    core.whitespace instructs git to flag certain whitespace problems:

    • trailing-space warns about whitespace at the end of a line or at the end of a file
    • space-before-tab warns when there is a space before a tab used for indentation

    apply.whitespace is used when applying a patch. It checks for whitespace errors (the ones listed above, in core.whitespace) and applies the patch after attempting to fix them (i.e., remove them).

    These options go in ~/.gitconfig -- that is, a .gitconfig file at the root of your user's home directory (typically /home/user/.gitconfig on Linux, /Users/user/.gitconfig on Mac OS X, and I don't know where on Windows but I suppose somewhere in C:\Documents and Settings\user).

提交回复
热议问题