쌓고 쌓다

깃허브에 실수로 중요정보(password)를 커밋했을때 본문

Git & CS

깃허브에 실수로 중요정보(password)를 커밋했을때

승민아 2023. 8. 12. 18:24

깃허브를 사용하며...

옛날에 DB정보를 관리하는 application.properties에 내가 자주 사용하는 비밀번호를 함께 적어놓은것이다.

물론 처음에는 gitignore도 쓸줄몰라서 초기에 application.properties를 커밋 제외를 시키지 않았다.

 

현재는 gitignore에 등록했으나 이미 예전의 커밋 히스토리에 내 비밀번호 등록과 삭제가 다 남아있다.

 

히스토리에서 모두 내 비밀번호 텍스트를 지울 수 있다. 물론 이 외에도 다양한 기능을 수행할 수 있다.

bfg repo-clear를 사용하자.

 

https://rtyley.github.io/bfg-repo-cleaner/

 

BFG Repo-Cleaner by rtyley

$ bfg --strip-blobs-bigger-than 100M --replace-text banned.txt repo.git an alternative to git-filter-branch The BFG is a simpler, faster alternative to git-filter-branch for cleansing bad data out of your Git repository history: Removing Crazy Big Files Re

rtyley.github.io

먼저 들어가서 .jar를 다운받는다.

 

지울 리포지토리의 사본을 담을 폴더를 만들어 그 안에 .jar 파일을 넣는다.

그리고 아래의 명령어를 수행한다.

git clone --mirror [리포지토리 https 주소]

EX) git clone --mirror https://github.com/a/b.git

 

그리고 지울 비밀번호가 담긴 .txt를 생성하여 같이 넣어주고 아래의 명령어를 수행하자.

java -jar bfg-1.14.0.jar --replace-text password.txt bootboard.git
(bootboard.git은 git clone으로 생긴 자기 이름.git으로 작성하자)

 

그리고 clone으로 생긴 자기 .git으로 현재 위치를 이동하여 아래의 명령어 수행

 

1. git reflog expire --expire=now --all && git gc --prune=now --aggressive
2. git push

 

결과

 

 

내가 입력한 password.txt에 있는 비밀번호가 존재하는 히스토리는

해당 부분을 모두 ***REMOVED***로 처리된다.

 

그 외 해당 폴더, 파일 모든 커밋 기록을 지우는 옵션도 존재한다.

https://rtyley.github.io/bfg-repo-cleaner/

 

BFG Repo-Cleaner by rtyley

$ bfg --strip-blobs-bigger-than 100M --replace-text banned.txt repo.git an alternative to git-filter-branch The BFG is a simpler, faster alternative to git-filter-branch for cleansing bad data out of your Git repository history: Removing Crazy Big Files Re

rtyley.github.io

 

'Git & CS' 카테고리의 다른 글

메모리 캐시에서 자꾸 가져올때 - 200 (from memory cache)  (0) 2023.09.27
gitignore 설정해도 application.properties 노출될때  (0) 2023.09.03
URL, URI  (0) 2023.07.30
MVC 패턴  (0) 2023.07.26
SSR, CSR  (0) 2023.07.19
Comments