[Git] gitignore 사용방법

하나·2022년 2월 17일
0

Git

목록 보기
5/5
post-thumbnail

Git .gitignore File 적용하기

.gitignore이란?

Project에 원하지 않는 Backup File이나 Log File , 혹은 컴파일 된 파일들을 Git에서 제외시킬수 있는 설정 File이다.

1. .gitignore 파일 만들기

항상 최상위 Directory에 존재해야한다.

2. 문법

# : comments

# no .a files
*.a

# but do track lib.a, even though you're ignoring .a files above
!lib.a

# only ignore the TODO file in the current directory, not subdir/TODO
/TODO

# ignore all files in the build/ directory
build/

# ignore doc/notes.txt, but not doc/server/arch.txt
doc/*.txt

# ignore all .pdf files in the doc/ directory
doc/**/*.pdf

3. 적용하기

.gitignore File을 같이 Push하면 된다.

(추가) .idea 디렉토리가 삭제 안될 때

git rm -rf .idea
git commit -m "delete .idea"
git push

참고 : https://stackoverflow.com/questions/32384473/gitignore-not-ignoring-idea-path, https://nesoy.github.io/articles/2017-01/Git-Ignore

0개의 댓글