개발
깃헙할 때 잊지말자 .gitignore
Hugh Q Lee
2022. 8. 5. 22:52
무작정 github에서 push 해보면 안다. 별 게 다 올라간다는 것을...
이때 '.gitignore'이라는 이름의 파일을 이용해서 git 관리에서 제외할 수 있다. 말 그대로 해당 파일에서 언급한 경로는 무시(ignore)하는 것이다.
https://www.toptal.com/developers/gitignore
gitignore.io
Create useful .gitignore files for your project
www.toptal.com
나는 보통 상기 링크에서 'macOS(혹은 windows), visual studio code, python' 이렇게 생성해 복붙한 다음 마지막에 내 custom 경로를 추가한다.
# 파일 경로
Root
|- models
|- my_model
|- obj_detection
|- models
|- model.py
|- .gitignore
# .gitignore
... 중략
### custom ignore
models/
최근 푸시에서 이슈가 있었는데, 위와 같은 상황에서 나의 의도는 'Root\models\'는 무시하고 'Root/obj_detection\models\' 경로는 무시하지 않는 것인데 두 경로 모두 무시하는 것이었다. 의도를 제대로 반영하기 위한 해결 코드는
# .gitignore
### custom
models/
!object_detection/models/
'''
if x != y 처럼
때때로 '!'가 not을 의미한다.
'''
폴더명이 같아 의도치 않게 ignore될 때는 잊지말자! 느낌표!!