Removing sensitive data from a repository

Jong Kim·2021년 6월 23일
0

잡동사늬

목록 보기
1/1

Problem

실수로 Secret Key를 안 빼두고 Githubpush 했덩;;
부랴부랴 .envSecret key들을 환경변수로 빼놓았으나,

from decouple import config

client_id = config('client_id')
Secret_Key = config('Secret_Key')

GithubCommit내역에 남아있는 Secret key들은 그대로...

git filter-branch

git filter-branch 로 해결 가능했덩.

git filter-branch --force --tree-filter "sed -i '' 's/7ong/***REMOVED***/' file.py"

repofile.py에 있는 "7ong"을 전부 "***REMOVED***"로 바꿔주는 마법~!
과거 commit 에 남아있는 기록들까지 전부 바꿔준덩.

--force 없이 해당 command를 여러 번 사용한다면,

Cannot create a new backup.
A previous backup already exists in refs/original/
Force overwriting the backup with -f

요런 error code가 뜨게 됩니덩;

마지막으로 force push 해주는 것 잊지마렁!!

Sum up

  1. git filter-branch --force --tree-filter "sed -i '' 's/[A]/[B]/' file.py"

  2. git push --force

Source

source_1

~끗~

profile
약해지지만 않는다면, 괜찮은 인생이야

0개의 댓글

관련 채용 정보