Git 커밋 작성자 수정하기
커밋할 때 실수로 잘못된 이메일을 쓰는 일이 꽤 자주 있어요. 용도별로 쓰고 싶은 이메일이 몇 개 있다 보니 정확하게 쓰는 게 중요하더라고요 :)
마지막 커밋의 작성자 수정하기
이 방법은 정말 간단해요!
git commit --amend --author="Example Name <[email protected]>"interactive rebase 사용하기
git rebase -i를 원하는 베이스에서 실행하세요- 수정하려는 커밋은
pick대신edit으로 표시하세요 git commit --amend --author="Example Name <[email protected]>"를 실행한 뒤git rebase --continue를 실행하세요
filter-branch 사용하기
전체 히스토리를 필터링하는 방법이에요! 다만 filter-branch는 부주의하게 다루면 문제가 생길 수 있으니 조심하세요
git filter-branch -f --commit-filter '
if [ "$GIT_AUTHOR_EMAIL" = "[email protected]" ];
then
GIT_AUTHOR_NAME="New Name";
GIT_AUTHOR_EMAIL="[email protected]";
git commit-tree "$@";
else
git commit-tree "$@";
fi' HEADfilter-repo 사용하기
git-filter-repo는 Git 저장소 분리하기에서 처음 소개했는데, 여기에서도 유용하게 쓸 수 있어요. filter-branch보다 권장되는 방법이지만 기본 Git 설치에는 포함되어 있지 않아요.
다음 명령어로 설치하세요
curl "https://raw.githubusercontent.com/newren/git-filter-repo/main/git-filter-repo" -o ~/.local/bin/git-filter-path그런 다음 아래 두 가지 방법 중 하나를 실행하세요
mailmap을 사용하는 경우
예전 주소 -> 새 주소로 매핑되도록 mailmap을 설정했다면 다음 명령어를 실행하면 돼요
git filter-repo --use-mailmapmailmap 없이 사용하는 경우
그렇지 않다면 다음 방법이 잘 동작해요
git filter-repo --email-callback '
return email if email != b"[email protected]" else b"[email protected]"
'글을 무작위로 읽기