0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Githubの歴史コミットのユーザ名とメールアドレスを変更する方法

Posted at

環境

  • Window 10
  • Git Bash

確認

まずは歴史記録を確認します
間違ったのはwrongNamewrongMail@example.comです

git log --pretty=full

commit 000111000111000111000 (HEAD -> master, origin/master)
Author: wrongName <wrongMail@example.com>
Commit: wrongName <wrongMail@example.com>

変更方法(ローカル)

正しいユーザー名を設定します

newName=correctName

正しいメールアドレスを設定します

newEmail=correctMail@example.com

ローカルのGit情報を変更します

git filter-branch -f --env-filter "GIT_AUTHOR_NAME='$newName'; GIT_AUTHOR_EMAIL='$newEmail'; GIT_COMMITTER_NAME='$newName'; GIT_COMMITTER_EMAIL='$newEmail';" HEAD

歴史記録を再確認して、正しいユーザー名とメールアドレスになりました

git log --pretty=full

commit 000111000111000111000 (HEAD -> master, origin/master)
Author: correctName <correctMail@example.com>
Commit: correctName <correctMail@example.com>

変更方法(GitHub)

ローカルで修正した情報をGithubに強制的にpushします

git push -f
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?