1단계: 표준 Node/Next/Vite .gitignore 생성
프로젝트 최상단 루트에 .gitignore 파일을 만들고 아래 항목을 저장합니다.
node_modules/
.next/
dist/
build/
.vercel/
.env
.env*.local
.DS_Store
*.log
2단계: 로컬 파일은 살려두고 Git 추적만 안전하게 해제
--cached 옵션을 쓰면 내 컴퓨터의 node_modules는 그대로 남고 Git 인덱스에서만 깔끔하게 제거됩니다.
git rm -r --cached node_modules
git add .gitignore
git commit -m "chore: untrack node_modules and add .gitignore"
git push
3단계: 이미 커밋된 저장소 용량까지 완전히 줄이고 싶다면
과거 커밋에 수백 MB가 남아 클론이 느린 경우 git-filter-repo --invert-paths --path node_modules/로 히스토리를 압축하면 저장소 크기가 1/50 수준으로 줄어듭니다.