예를 들어 .env파일을 잘못 올린경우 새로운 commit을 올리더라도 commit 히스토리에 남게된다.
이때, 전체 히스토리에서 필터링해 제거할 수 있다.
주의) 로컬 저장소에서도 필터링 되기 때문에 삭제된다.
특히 파일명이 아니고 경로로 지정해야합니다.
$ git filter-branch -f --index-filter 'git rm --cached --ignore-unmatch .env' --prune-empty -- --all
//윈도우 유저는 ""<<이걸로 사용해야 적용됩니다 (bad revision error)
$ git filter-branch -f --index-filter "git rm --cached --ignore-unmatch .env" --prune-empty -- --all
https://stackoverflow.com/questions/32715034/removing-files-from-git-history-bad-revision-error
.env라고 적힌 부분은 삭제할 path를 적어주면 된다.
그 후 강제 push 해주면 전체 commit history 내역에서 해당파일이 삭제된다.
$ git push origin [branch명] --force
'웹 개발 공부중' 카테고리의 다른 글
[web] LocalStorage, SessionStorage, Cookie의 차이점 (0) | 2022.07.12 |
---|---|
클라이언트/서버/API (0) | 2022.01.19 |
인스타 클론 코딩 작업중 (0) | 2021.12.26 |
pymongo CRUD (0) | 2021.12.15 |
mongoDB시작하기 (0) | 2021.12.15 |