Git Repository가 무거워지거나 DB 비밀번호가 유출되는 대참사를 막기 위해 바로 복사해서 덮어씌울 수 있는 완성된 .gitignore 코드를 드립니다. 프로젝트 루트(Root) 경로

 Git Repository가 무거워지거나 DB 비밀번호가 유출되는 대참사를 막기 위해 바로 복사해서 덮어씌울 수 있는 완성된 .gitignore 코드를 드립니다. 프로젝트 루트(Root) 경로


지금 주신 .gitignore는 Node.js(React)와 에디터 기본 설정만 포함되어 있습니다. 우리가 구축하는 FastAPI 백엔드(Python), 보안을 위한 환경 변수(.env), 그리고 대용량 영상 파일이 저장되는 볼륨 디렉토리에 대한 예외 처리가 누락되어 있습니다.

실무에서 Git Repository가 무거워지거나 DB 비밀번호가 유출되는 대참사를 막기 위해 바로 복사해서 덮어씌울 수 있는 완성된 .gitignore 코드를 드립니다. 프로젝트 루트(Root) 경로에 두시면 됩니다.

.gitignore

Plaintext
# ==========================================
# 1. Node.js & React Frontend (기존 내용 포함)
# ==========================================
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

# Dependencies & Build
node_modules/
dist/
dist-ssr/
build/
.local

# ==========================================
# 2. Python & FastAPI Backend (추가 필수)
# ==========================================
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# Virtual Environments
venv/
.venv/
env/
.env_python/

# FastAPI / Pytest cache
.pytest_cache/
.mypy_cache/

# ==========================================
# 3. Security & Environment Variables (보안 핵심)
# ==========================================
# 환경 변수 파일은 절대 Git에 올라가면 안 됩니다.
.env
.env.local
.env.development
.env.production
*.pem

# ==========================================
# 4. Media Storage & Docker Volumes (프로젝트 특화)
# ==========================================
# 인코딩 중인 임시 파일, 원본 mp4, m3u8, ts 파일 등 용량이 큰 미디어 파일 제외
/backend_player/videos/
/backend/storage/
/video_storage/
*.mp4
*.m3u8
*.ts

# MariaDB 로컬 데이터 볼륨 마운트 제외
/db_data/

# ==========================================
# 5. OS & Editor directories and files
# ==========================================
.vscode/*
!.vscode/extensions.json
.idea/
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
Thumbs.db

사수의 조언: 특히 3번(보안)과 4번(미디어 파일) 항목이 중요합니다. .env 파일에 들어갈 MariaDB 비밀번호나, 인코딩을 위해 업로드된 기가바이트(GB) 단위의 .mp4 영상이 Git에 푸시(Push)되면 히스토리를 전부 지워야 하는 대형 사고가 발생합니다. 위 설정을 적용한 뒤 코드를 커밋(Commit)하시기 바랍니다.

댓글

가장 많이 본 글