본문 바로가기
개발

[git] 특정 파일 잘못 올린 상태로 커밋했을 때, git에서 특정 파일 제거하는 방법

by kks950115 2024. 2. 29.
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

 

 

출처: https://velog.io/@nohsangwoo/git-%ED%8A%B9%EC%A0%95%ED%8C%8C%EC%9D%BC%EB%A7%8C-%EB%AA%A8%EB%93%A0-%EC%BB%A4%EB%B0%8B%EC%97%90%EC%84%9C-%EC%A0%9C%EA%B1%B0%ED%95%98%EA%B8%B0

728x90
반응형

댓글