git을 사용하다보면 중앙 저장소에 불필요한 파일을 실수로 올리는 경우가 있다. 이러한 경우에는 gitIgnore 를 설정하여도 로컬 저장소에서 해당 파일을 무시만 할 뿐 중앙저장소에서의 파일은 삭제되지 않는다. 그래서 중앙 저장소에 불필요한 파일을 삭제하는 방법을 기록해 놓으려고 한다.
아래의 방법은 명령프롬프트에서 프로젝트 폴더로 이동하여 작업해야한다.
// 파일의 경우
git rm "target File"
git rm --cached "target File"
// 폴더의 경우
git rm -r "target Folder"/
git rm --cached -r "target Folder"/
// 변경 내용 commit
git commit -m "commit message" [ ex) git commit -m "delete config file or folder" ]
// 변경 내용 중앙저장소 push
git push origin "branch"
// 파일의 경우
git rm --cached "target File"
// 폴더의 경우
git rm --cached -r "target Folder"/
// 변경 내용 commit
git commit -m "commit message" [ ex) git commit -m "delete config file or folder" ]
// 변경 내용 중앙저장소 push
git push origin "branch"
지저분한 중앙 저장소의 내용들을 모조리 지워보자.