더북(TheBook)
data/

Q .gitignore에 다른 항목도 추가하려고 합니다!


A 특정 디렉터리뿐만 아니라 다양하게 제외 항목을 지정할 수 있습니다. ➊ *를 사용해서 확장자가 temp인 파일을 제외합니다. ➋ *.temp 항목으로 확장자가 temp인 파일은 모두 제외하지만 ‘!’로 지정한 exception.temp는 제외하지 않습니다. ➌ 하위 디렉터리 data에서 확장자가 tmp인 파일은 제외합니다. 하지만 data보다 아래 디렉터리에 존재하는 확장자가 tmp인 파일은 제외하지 않습니다. ➍ data 디렉터리 아래에 존재하는 확장자가 tmp인 파일은 모두 제외합니다.

*.temp ➊
!exception.temp ➋
data/*.tmp ➌
data/**/*.tmp ➍

 

git add 명령으로 준비 영역에 파일을 추가합니다. 많은 파일을 동시에 추가해야 하므로 ➊ 파일 목록을 .으로 지정합니다. ➋ git status로 확인해 보면 관리 대상 파일 중에 .gitignore에 지정한 data 디렉터리가 제외되었음을 알 수 있습니다.

administrator@vmgate:~/code/environments/production$ git add . ➊
administrator@vmgate:~/code/environments/production$ git status ➋
On branch master

No commits yet

Changes to be committed:
  (use "git rm --cached <file>..." to unstage)
    new file:   .gitignore
    new file:   environment.conf
    new file:   hiera.yaml
    new file:   manifests/site.pp
    new file:   manifests/site.pp.old
    new file:   modules/apache/.geppetto-rc.json
    new file:   modules/apache/.github/workflows/release.yml
    new file:   modules/apache/.github/workflows/weekly.yml
    new file:   modules/apache/.github_changelog_generator
...