Git Filter Repo

고급 Git

Amanda Crawford-Adamo

Software and Data Engineer

git filter-repo란?

Git filter-repo 명령어

git filter-repo

Git 기록을 빠르고 안전하게 재작성하는 도구입니다.

  • 파일/디렉터리 이름 변경
  • 모든 브랜치에 동시에 적용

용도

  1. 민감정보 제거(예: 비밀번호, 토큰)
  2. 불필요한 파일 정리
  3. 저장소 구조 재정비
  4. 저장소 크기 감소
고급 Git

Filter-Repo 프로세스

  1. pip으로 git filter-repo 설치

    pip install git-filter-repo
    
  2. 모든 커밋에서 secrets.txt 제거

    git filter-repo --path secrets.txt --invert-paths
    

Filter-Repo 관련 옵션

--path: 작업 대상 경로 지정

--invert-paths: --path에 지정한 경로를 제외하고 적용

고급 Git

Filter-Repo 결과

출력

  Parsed 150 commits
  New history written in 0.10 seconds; now repacking/cleaning...
  Repacking your repo and cleaning out old unneeded objects

핵심 영향

  • 모든 브랜치와 커밋이 업데이트됨
  • 모든 커밋 해시가 변경됨
  • 이후 강제 푸시 필요
  • 팀원들은 저장소를 다시 클론해야 함
고급 Git

filter-repo 사용 시점

사용 예시

  • 민감정보 제거(예: 비밀번호)
  • 비대해진 저장소 정리
  • 모든 커밋에서 파일 이름 변경·재구성

  • 실행 전 항상 저장소를 백업하십시오
  • 기록을 재작성해 푸시하기 전 협업자와 조율하십시오
고급 Git

연습해 봅시다!

고급 Git

Preparing Video For Download...