Public repo로 갈 때 commit author 메일이 노출되면

블로그를 Public으로 전환하는 과정에서 한 가지 함정을 발견했어요. 모든 commit의 author 필드에 회사 메일(나@회사도메인)이 그대로 박혀있던 것이에요. Private 시절에는 신경도 안 썼는데, Public 가는 순간 commit history 전체가 노출되니 외부에서 바로 보이게 돼요.

이걸 일괄 마스킹한 과정을 정리해뒀어요.

문제 — git config가 그대로 박혀버림

Mac에서 git을 처음 셋업할 때 흔히 이렇게 하잖아요:

git config --global user.name "name"
git config --global user.email "name@company.com"

이 글로벌 설정이 모든 repo의 모든 commit author로 들어가요. Private repo에서는 어차피 본인만 보니까 신경 쓸 일이 없는데, Public으로 전환하는 순간 commit history 전부에 그 메일이 노출됩니다.

GitHub UI에서 commit을 클릭하면 author 메일이 바로 보여요. 검색 봇도 긁어가요.

해결 — GitHub의 noreply 메일 사용

GitHub은 사용자별로 자동 생성되는 noreply 주소를 제공해요:

{user-id}+{username}@users.noreply.github.com

이 주소는:

  • ✅ 본인 GitHub 계정과 자동 연결됨 (Contribution 그래프 정상 카운트)
  • ✅ 실제 메일은 외부에 절대 노출 안 됨
  • ✅ Public repo에서 상시 사용 권장

본인 noreply 주소 찾기

https://github.com/settings/emails 페이지로 가면 “Keep my email addresses private” 영역에 본인 noreply 주소가 표시돼있어요.

추가로 두 옵션을 켜두면 좋아요:

  • Keep my email addresses private — 모든 외부 인터페이스에서 메일 마스킹
  • Block command line pushes that expose my email — 실수로 회사 메일로 commit 후 push하면 GitHub이 자동 차단

Step 1: 로컬 git config 변경

git config user.name "username"
git config user.email "{user-id}+{username}@users.noreply.github.com"

⚠️ --global 안 씀. 개인 repo에서만 noreply 쓰고 싶을 수도 있으니 해당 repo에서만 설정.

Step 2: 기존 commit 일괄 재작성

이미 push된 commit들의 author도 다 바꿔야 해요. git filter-branch를 씁니다:

git filter-branch -f --env-filter '
export GIT_AUTHOR_NAME="username"
export GIT_AUTHOR_EMAIL="{user-id}+{username}@users.noreply.github.com"
export GIT_COMMITTER_NAME="username"
export GIT_COMMITTER_EMAIL="{user-id}+{username}@users.noreply.github.com"
' -- --all

--all은 모든 ref(브랜치, tag)에 적용. 단일 브랜치만 하려면 -- main 같이 지정.

💡 더 안전한 도구는 git filter-repofilter-branch는 deprecated 경고가 떠요. 다만 별도 설치 필요해서, 한 번만 쓸 거라면 filter-branch도 OK.

Step 3: Force-push

git push origin main --force
git push origin v4 --force

⚠️ Force-push는 위험해요. 협업 repo에서는 사전 합의 필수. 개인 블로그 repo니까 그냥 밀어버려도 OK.

--force-with-lease 옵션으로 원격이 내 마지막 fetch 이후 변경되지 않았을 때만 강제 push할 수도 있어요. 더 안전하지만, filter-branch 후에는 lease 검사가 stale로 잡혀서 거부될 수 있음.

Step 4: 백업 정리 (중요!)

filter-branch는 자동으로 refs/original/원본 commit 백업을 남겨둬요. 이걸 안 지우면 force-push 했어도 로컬 repo에는 옛 메일이 그대로 살아있게 돼요.

# 백업 ref 삭제
rm -rf .git/refs/original/
 
# reflog 즉시 만료
git reflog expire --expire=now --all
 
# Garbage collection으로 unreachable object 제거
git gc --prune=now --aggressive

Step 5: 최종 검증

# 모든 ref에서 author 메일 분포 확인
git log --all --format='%ae' | sort -u

이 출력에 오직 noreply 메일 하나만 떠야 해요. 다른 메일이 보이면 refs/original/ 정리가 덜 된 거예요.

한 가지 더 — Local repo의 git config

git config user.email도 noreply로 바꿔놓는 걸 잊지 마세요. 안 그러면 다음 commit부터 또 회사 메일이 박힙니다.

git config user.name
git config user.email
# → noreply 주소 떠야 함

정리 — 권장 안전 절차

  1. Public 전환 전에 본인 noreply 주소 확보
  2. 로컬 git config 먼저 noreply로 변경
  3. filter-branch로 history 일괄 재작성
  4. force-push 전에 --force-with-lease 시도, 안 되면 그냥 --force
  5. refs/original/ 정리 + reflog expire + gc
  6. git log --all --format='%ae' | sort -u로 검증
  7. GitHub Settings에서 Block command line pushes that expose my email 활성화

이 과정을 한 번 거치면, 다음부터는 GitHub이 알아서 막아주니까 같은 실수를 안 반복해요.

배운 점

Private → Public 전환은 단순한 visibility 토글이 아니라 모든 메타데이터를 외부에 공개하는 행위예요. Author 메일은 시작에 불과하고, commit message에 무심코 박은 사내 URL, 패스워드 같은 것도 같이 검토해야 해요. 가능하면 Public repo는 처음부터 Public으로 만들기 — 그래야 처음부터 안전한 메타데이터로 시작할 수 있어요.