Git-Ignore 사용법


Why .gitignore?

  • git으로 관리할 필요 없는 애들: package file 이나 result file 들
  • git으로 관리하며 안되는 애들: security 때문에 공유하면 안되는 파일들 !!!
    #secrets.yaml
    id: admin
    pw: 1234abcd
    
  • 이런 보안관련 파일이 있을 때, .gitingore 만들어서 …
    1
    2
    
    #.gitingore
    secrets.yaml
    
  • git status를 쳐보면, secrets.yaml 정보가 사라짐.

.gitignore 형식

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# 이렇게 #를 사용해서 주석 

# 모든 file.c 
file.c 

# 최상위 폴더의 file.c 
/file.c 

# 모든 .c 확장자 파일 
*.c 

# .c 확장자지만 무시하지 않을 파일
!not_ignore_this.c 

# logs란 이름의 파일 또는 폴더와 그 내용들 
logs 

# logs란 이름의 폴더와 그 내용들 
logs/ 

#logs 폴더 바로 안의 debug.log와 .c 파일들 
logs/debug.log 
logs/*.c 

# logs 폴더 바로 안, 또는 그 안의 다른 폴더(들) 안의 debug.log 
logs/**/debug.log

Reference

Notes Mentioning This Note

Table of Contents


Share on: