기술 관련 글2016. 8. 9. 14:25

아무래도 개인적인 취향으로 Windows에서 개발하는게 너무 편하다고 느끼고 있다.


그래서 Windows에서도 git을 사용하게 되는데, git-diff를 하게 되면 ^M이 골칫거리가 될 수 있다.


물론 core.autocrlf를 true로 설정하면, checkout 할 때는 Windows style(CRLF)로, push할 때는 UNIX style(LF)로 처리해 주는 옵션이 있는데, 기존의 repository를 이용하거나 기타 상황에서는 불편한 경우가 생기기도 한다.


그래서 찾아봤더니 core.whitespace라는 옵션이 있고, 값에 cr-at-eol을 추가 해 주면 ^M으로 표시되는 CR이 git-diff에서 무시된다.


git config에 대한 help 페이지를 보면, 아래와 같이 설명이 되어 있다.

core.autocrlf

Setting this variable to "true" is almost the same as setting the text attribute to "auto" on all files except that text files are not guaranteed to be normalized: files that contain CRLF in the repository will not be touched. Use this setting if you want to have CRLF line endings in your working directory even though the repository does not have normalized line endings. This variable can be set to input, in which case no output conversion is performed.


Console에서 아래와 같이 입력하면 설정이 가능하다.

git config --global core.whitespace cr-at-eol


자세한 설명은 google로 검색했던 다음 사이트를 참고하면 된다.

https://lostechies.com/keithdahlby/2011/04/06/windows-git-tip-hide-carriage-return-in-diff/


Posted by 세월의돌