#TIL #git gitignore에 / 문자가 앞에 있고 없고

$ cat .gitignore
*.c
$ git status --ignored --short
!! main.c
!! test/main_test.c

/ 문자가 없다. 모든 디렉터리를 대상으로 glob 패턴에 일치하는 파일을 무시한다.

$ cat .gitignore
/*.c
$ git status --ignored --short
?? test/main_test.c
!! main.c

/ 문자가 있다. 그것도 제일 앞에. pathname 시작과 일치해야 한다. 그 뒤에 따라오는 * 문자는 / 문자 같은 경로 구분자(path separator)와는 매치가 안 된다. 그래서 main.c 파일은 매치되고 test/main_test.c 파일은 매치 안 된다. 즉, 매치되는 main.c 파일만 무시된다.

참고 - https://git-scm.com/docs/gitignore

Feedback plz <3 @ohyecloudy, ohyecloudy@gmail.com

A Random Post