본문 바로가기
카테고리 없음

[Git] CRLF warning

by TSpoons 2024. 11. 10.

 
git add . 했는데?? 

warning: in the working copy of 'PinChangeInterrupt/PinChangeInterrupt/Debug/Makefile', LF will be replaced by CRLF the next time Git touches it
warning: in the working copy of 'PinChangeInterrupt/PinChangeInterrupt/fnd.c', LF will be replaced by CRLF the next time Git touches it
warning: in the working copy of 'PinChangeInterrupt/PinChangeInterrupt/main.c', LF will be replaced by CRLF the next time Git touches it

 
 

git reset

git add .
warning: in the working copy of 'PinChangeInterrupt/PinChangeInterrupt/Debug/Makefile', LF will be replaced by CRLF the next time Git touches it
warning: in the working copy of 'PinChangeInterrupt/PinChangeInterrupt/fnd.c', LF will be replaced by CRLF the next time Git touches it
warning: in the working copy of 'PinChangeInterrupt/PinChangeInterrupt/main.c', LF will be replaced by CRLF the next time Git touches it

git config --global core.autocrlf true
  • 경고 메시지는 줄 바꿈 문자(LF와 CRLF)가 다를 때 발생합니다.
  • core.autocrlf 설정을 통해 줄 바꿈 문자를 자동으로 변환하거나 변환하지 않도록 설정할 수 있습니다.
    • core.autocrlf=true: Windows에서 LF를 CRLF로 변환.
    • core.autocrlf=input: Linux/macOS에서 LF를 유지.
    • core.autocrlf=false: 줄 바꿈 변환 안 함.
  • 이미 커밋된 파일에서 줄 바꿈 문제를 수정하려면, 해당 파일을 스테이징에서 제거한 후 다시 추가하고 커밋하는 방법을 사용합니다.

이 방법을 통해 Windows와 Unix 기반 시스템에서 발생할 수 있는 줄 바꿈 문제를 해결할