본문 바로가기

언어/git

[git] 암호관련 파일 (이력 포함) 삭제

OS : macOS

 

목적 : 암호가 적힌 파일 완전 삭제

이유 : git은 버전관리로 파일을 다 확인 할 수 있으므로 파일 삭제 후 push 한다고 해서 못보는 것이 아니기 때문

주의사항 : 중간에 파일이 삭제되므로 백업 후 진행해야 합니다.

 

필요 설치 사항

 - git

 - git filter-repo

 

git filter-repo 설치

brew install git-filter-repo

파일 삭제 및 이력삭제 ( 로컬정보에서 이력정보 삭제되었는지 확인 가능함 )

주의사항 : 파일도 삭제됨

# git filter-repo --invert-paths --path 파일위치 
git filter-repo --invert-paths --path src/main/resources/application-real.yml

.gitignore 파일 정보 추가

echo "src/main/resources/application-real.yml" >> .gitignore

수정 정보 add 및 commit

git add -A
git commit -m "암호정보 전체 삭제"

최종 push

# git push origin [브랜치명] --force --tags
git push origin --force --tags

 

참고

https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/removing-sensitive-data-from-a-repository

 

Removing sensitive data from a repository - GitHub Docs

The git filter-repo tool and the BFG Repo-Cleaner rewrite your repository's history, which changes the SHAs for existing commits that you alter and any dependent commits. Changed commit SHAs may affect open pull requests in your repository. We recommend me

docs.github.com

 

'언어 > git' 카테고리의 다른 글

[github] token정보를 이용하여 eclipse에 소스 다운로드  (0) 2022.04.29
[github] token 생성  (0) 2022.04.29