프로그래밍/Git & GitHub
.gitignore 작성
L.Joey
2023. 7. 18. 15:56
작성하는 이유?
- 로그 파일, 빌드 결과 파일등 직접 수정할 필요 없고 버전관리에 불필요한 파일 업로드 방지
자동생성 사이트
- 사용하는 IDE, 언어 입력하면 자동으로 생성
https://www.toptal.com/developers/gitignore
gitignore.io
Create useful .gitignore files for your project
www.toptal.com
설정 방법
- # : 주석
- *.log : 확장자가 .log 로 끝나는 모든 파일을 무시
- 폴더이름/ : 폴더 이름안에 있는 모든 파일을 무시
- /파일이름 : 현재 폴더에 있는 특정 파일 무시
- 무엇을 해야 할지 모르면 https://github.com/github/gitignore 참고
추가 방법
- 최상위 폴더에 위치시키기
- 이미 추가한 파일을 무시하고 싶으면, .gitignore을 커밋하기전에 추가된 파일의 추적을 해제필요
git rm --cached <file name or .(all)>
---> git add . 를 하고나서 내가 원하지 않는 파일 혹은 폴더가 추가 되었다면
git rm --cached -r 파일명 혹은 폴더명
- -r : 재귀적 제거를 허용합니다
참고한 곳
https://www.git-scm.com/book/en/v2/Git-Basics-Recording-Changes-to-the-Repository
https://docs.github.com/en/get-started/getting-started-with-git/ignoring-files