5
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

git - インデントのスペースだけの diff を無視する

Posted at

Sublime Text がいつの間にかソースコード全体に re indent してしまう場合があり、困っていた。
上記 URL によれば git にそんなコンフィグはないよ と。

代わりにdiff のオプションとして--ignore-space-change というのがあるのでこれを利用すればなんとかなる。

$ git diff --ignore-space-change --no-prefix -- indent_mixed_file.txt > ignore_SP.diff
$ git checkout indent_mixed_file.txt
$ cat ignore_SP.diff | patch -p0

上から順番に説明すると以下の通り。

  1. --ignore-space-change でパッチを作成して
  2. チェックアウトしてファイルをリセット
  3. (1)のパッチを当てる。
5
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?