Daily Develope

[Git] .gitignore 작성 본문

Git

[Git] .gitignore 작성

noggame 2022. 1. 7. 19:27

예외항목 지정 예시

*.log        # 확장자가 log인 파일 예외
!result.log    # log 확장자가 예외처리 되었더라도 result.log 파일은 commit
dirA/**/*    # dirA 폴더 내부 모든 폴더 및 파일 예외

적용시 주의사항

: 이미 push된 프로젝트에서는 .gitignore 관련파일을 캐쉬에서 삭제 후 commit

  • 전체목록 갱신
git rm -r --cached .
git commit -a -m "set .gitignore"
git push -u origin master
  • 특정파일만 예외처리 (예_ temp.log 파일 제외)
git rm --cached temp.log
echo temp.log >> .gitignore
# git status 확인 시 temp.log 파일이 제외(deleted)된 것을 볼 수 있다.
git commit -m "update .gitignore"
Comments