개발
[git] 특정 파일 잘못 올린 상태로 커밋했을 때, git에서 특정 파일 제거하는 방법
kks950115
2024. 2. 29. 11:45
728x90
용량이 큰 exe 파일을 넣어둔 걸 깜빡하고 커밋해서 push할 때마다 용량제한에 걸렸다. 로컬에서 exe파일을 삭제했음에도 불구하고 깃 내부에서 기록이 남아있는지 exe파일을 계속 푸쉬하려고 하면서 용량 초과 메시지를 띄운다.
파일 제거
git filter-branch --force --index-filter 'git rm --cached --ignore-unmatch 파일명' --prune-empty --tag-name-filter cat -- --all
경로 존재하면 경로+파일명
ex) root/src/components/PostsButtons.js
git filter-branch --force --index-filter 'git rm -r --cached --ignore-unmatch /src/components/PostsButtons.js' --prune-empty --tag-name-filter cat -- --all
728x90
반응형