개발이야기
github 공백무시 diff 하기
준호씨
2016. 2. 14. 17:30
반응형
github 에서 commit 내역을 보면 가끔 indent 수정으로 인한 diff 결과가 보기 싫을 때가 있다.
예를 들면 아래와 같은 경우이다.
사실 printf("nice to meet you\n"); 와 return 0; 는 공백만 변경 되었을 뿐 내용의 변화는 없다.
#include <stdio.h> | ||
int main() { | ||
- printf("nice to meet you\n"); | ||
- printf("hello world"); | ||
- return 0; | ||
+ printf("good to meet you\n"); | ||
+ printf("nice to meet you\n"); | ||
+ printf("hello world\n"); | ||
+ return 0; | ||
} |
공백을 무시하고 diff 결과를 볼 수 있으면 좋겠다는 생각이 든다.
에 팁이 있다. 주소 마지막에 ?w=1 를 추가 하면 된다.
를 아래와 같이 ?w=1 를 추가 한다.
아래와 같이 좀 더 보기 좋게 나온다.
#include <stdio.h> | ||
int main() { | ||
+ printf("good to meet you\n"); | ||
printf("nice to meet you\n"); | ||
- printf("hello world"); | ||
+ printf("hello world\n"); | ||
return 0; | ||
} |
이번 예제는 비교적 짧아서 뭐가 좋아 진지 잘 모를 수도 있지만 파일이나 코드양이 많아 지면 이 기능은 진가를 발휘하게 된다.
git 커맨드에도 -w 옵션이 있다고 하니 커맨드라인이 익숙한 사용자는 git diff -w (--ignore-all-space) 을 이용하면 되겠다.
git help diff 해 보면 관련 옵션 설명을 찾아 볼 수 있다.
-w, --ignore-all-space
Ignore whitespace when comparing lines. This ignores differences even if one line has whitespace where the other line has none.
아래와 같이 eol 공백 무시 하는 기능도 있다.
--ignore-space-at-eol
Ignore changes in whitespace at EOL.
반응형