29
17

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 -bとgit diff -wの違いを調べた

Posted at

はじめに

git diffのヘルプを読んでみた。

-b, --ignore-space-change
           Ignore changes in amount of whitespace. This ignores whitespace at line end, and considers all other sequences of one or more whitespace characters to be equivalent.

-w, --ignore-all-space
           Ignore whitespace when comparing lines. This ignores differences even if one line has whitespace where the other line has none.

要約すると
git diff -bはスペースの違いを無視する(ignore-space-change)
git diff -wは全てのスペースの差分を無視する(ignore-all-space)

ふむふむなるほどよく分からん。
-wの方は全てを無視するから単純で理解しやすい。
-bの方はもう少し挙動を調べる必要がある。

git diff -bの挙動

a = b
  ↓
a =                      b

ってやっても差分は出ない
ただし

a=b
 ↓
a=     b

ってやると差分が出る
要するに既にあるスペースにいくらスペースを足しても差分として無視するけど、新規のスペースは無視しないっていう感じっぽい

おわりに

違いが分からずに使っていて差分もよく分からず見ていたけど挙動が分かってスッキリ

29
17
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
29
17

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?