본문 바로가기
Etc

TIL | git 폴더명 대소문자 이슈

by J-Ymini 2022. 1. 29.

git 파일 및 폴더명 대소문자 오류

  • 최근 프로젝트를 진행하면서 컴포넌트의 폴더 구조 및 이름을 수정하던 도중, 폴더 명의 대소문자를 변경했음에도 불구하고 해당 변경 사항이 반영되지 않은 채 devmerge 되어 빌드 오류가 지속적으로 났다. 확인해보니 git config core.ignorecase에 대한 이슈였다.

 

git config core.ignorecase

Internal variable which enables various workarounds to enable Git to work better on filesystems that are not case sensitive, like APFS, HFS+, FAT, NTFS, etc. For example, if a directory listing finds "makefile" when Git expects "Makefile", Git will assume it is really the same file, and continue to remember it as "Makefile".

The default is false, except git-clone[1] or git-init[1] will probe and set core.ignoreCase true if appropriate when the repository is created.

  • git 공식문서의 내용을 바탕으로 간단히 정리하자면, git은 기본적으로 파일 및 폴더명의 대소문자를 따로 구분하지 않는다. 때문에 git config core.ignorecaseboolean값을 변경함으로써 대소문자를 구별하도록 설정할 수 있다. (이전에 작업할때는 파일의 대소문자 변경은 정상적으로 반영이 되고 폴더명만 반영이 되지 않았다.. 뭐지?.. )
  • git init이나 git clone을 통해 생성이 된 git의 경우, 기본값은 true이다. 때문에 대소문자를 구별할 수 없었던 것이었다.(실제로 확인해보니 CRA, NEXTjs 프로젝트 또한 기본값이 true로 설정되어 있음을 알 수 있었다.)
  • 결론적으로 git config core.ignorecasefalse로 설정하면, 대소문자 변경에 대한 인식을 할 수 있다.

 

Reference