git 특정파일만 모든 커밋에서 제거하기

sangwoo noh·2021년 7월 28일
1

git

목록 보기
1/13
post-thumbnail

과거에 이미 실수로 env파일을 github저장소에 올렸다던지 뭐 중요한 키를 올렸었는데 모르고 계속 커밋했을때 후속조치로 관련된 모든 커밋에서 해당 파일 삭제 법

파일 제거

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
profile
하기로 했으면 하자

0개의 댓글