Gitコミットには「Author(作成者)」と「Committer(コミット適用者)」が記録されます。
まれにこれらの変更の必要に迫られることがあるので、後から変更・修正する方法を説明します。
Committer と Author の確認方法#
git show や git log はデフォルトでは Author しか表示しませんが、オプション --pretty=fuller をつければ Committer も表示されます。
例えば下記のようになります。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
| $ git show HEAD --name-status --pretty=fuller
commit 190066b4eb8b7a1b1cda2fecdf5a6b70a1da703b
Author: Joel Rosdahl <joel@rosdahl.net>
AuthorDate: Thu Mar 12 08:31:19 2026 +0100
Commit: Joel Rosdahl <joel@rosdahl.net>
CommitDate: Thu Mar 12 08:44:12 2026 +0100
test: Fix remote_helper test error for long $PWD
Use relative Unix socket paths in tests to avoid overflowing the Unix
socket name length limit when $PWD is long.
Fixes #1697.
M test/suites/remote_helper.bash
|
自分でコードを書いて自分でコミットする場合は上記のようにどちらも同じ人になります。
他の人が git cherry-pick したりすると Author と Committerが 別の人になったりします。
この Author や Committer は基本的に後から変更したりすることはないのですが、ごく稀に変更したくなる場合があります。
原則としてそのような無法なことはしてはいけませんが、時と場合によっては必要になることもあるかもしれません。
今回はそのCommitterとAuthorの名前およびメールアドレス、コミット時刻の変更方法を説明します。
Warning
AuthorやCommitterを歴史改変するのはVCSとしてご法度です。
すでにpush済みの履歴を書き換えた場合、サーバーに反映させるには git push --force が必要になり、他の共同開発者に多大な迷惑がかかります。
自分しか使っていないリポジトリなら自由ですが、共同開発のときはよくよく考えて使用してください。
最新コミットの Committer Author の変更#
最新コミットのコミットログを修正するには git commit --amend を使用します。
このコマンドを利用することで Committer, Author を変更できます。
--no-edit も併用すると、いちいちコミットログの修正画面が立ち上がらないので便利です。
git push する前なら影響を最小限にして変更ができます。
Committer の修正#
GIT_COMMITTER_NAME, GIT_COMMITTER_EMAIL, GIT_COMMITTER_DATE 変数を利用すればできます。
下記の例では「YAMADA Taro」さんが「日本時間 2025-08-03 01:23」にコミットしたということに修正しています。
メールアドレスは hogehoge@example.com です。
使える時刻のフォーマットはいくつかありますが、好きなものを好みで使えばよいです。
RFC 2822だと Thu, 07 Apr 2005 22:13:13 +0200 のようになります。
ISO 8601だと 2005-04-07T22:13:13 のようになります。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
| $ git show HEAD --name-status --pretty=fuller
commit 190066b4eb8b7a1b1cda2fecdf5a6b70a1da703b
Author: Joel Rosdahl <joel@rosdahl.net>
AuthorDate: Thu Mar 12 08:31:19 2026 +0100
Commit: Joel Rosdahl <joel@rosdahl.net>
CommitDate: Thu Mar 12 08:44:12 2026 +0100
test: Fix remote_helper test error for long $PWD
Use relative Unix socket paths in tests to avoid overflowing the Unix
socket name length limit when $PWD is long.
Fixes #1697.
M test/suites/remote_helper.bash
$ GIT_COMMITTER_DATE="2025-08-03T01:23:45+09:00" GIT_COMMITTER_NAME="YAMADA TARO" GIT_COMMITTER_EMAIL="hogehoge@example.com" git commit --amend --no-edit
[detached HEAD 57466d8] test: Fix remote_helper test error for long $PWD
Author: Joel Rosdahl <joel@rosdahl.net>
Date: Thu Mar 12 08:31:19 2026 +0100
1 file changed, 2 insertions(+), 2 deletions(-)
$ git show HEAD --name-status --pretty=fuller
commit 57466d8ad3ad20a248a3202842715c4b7a3961c6 (HEAD)
Author: Joel Rosdahl <joel@rosdahl.net>
AuthorDate: Thu Mar 12 08:31:19 2026 +0100
Commit: YAMADA TARO <hogehoge@example.com>
CommitDate: Sun Aug 3 01:23:45 2025 +0900
test: Fix remote_helper test error for long $PWD
Use relative Unix socket paths in tests to avoid overflowing the Unix
socket name length limit when $PWD is long.
Fixes #1697.
M test/suites/remote_helper.bash
|
Author の修正#
Author の変更は --author --date を使用します。
--author のフォーマットは USER Name <hogehoge@example.com> のようになります。
下記の例では「YAMADA TARO」さんが、書いたコードを「日本時間 2025-08-03 01:23」にコミットしたということに修正しています。
ただし、このままAuthorを変更するとCommitterが今現在のアカウントに更新されてしまいます。
下記の例ではJoel RosdahlさんからNAGAYASU ShinyaさんにCommitterが更新されています。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
| $ git show HEAD --name-status --pretty=fuller
commit 190066b4eb8b7a1b1cda2fecdf5a6b70a1da703b
Author: Joel Rosdahl <joel@rosdahl.net>
AuthorDate: Thu Mar 12 08:31:19 2026 +0100
Commit: Joel Rosdahl <joel@rosdahl.net>
CommitDate: Thu Mar 12 08:44:12 2026 +0100
test: Fix remote_helper test error for long $PWD
Use relative Unix socket paths in tests to avoid overflowing the Unix
socket name length limit when $PWD is long.
Fixes #1697.
M test/suites/remote_helper.bash
$ git commit --amend --no-edit \
--author="YAMADA Taro <hogehoge@example.com>" \
--date="2025-01-23T01:23:45+09:00"
[detached HEAD 110f2d5] test: Fix remote_helper test error for long $PWD
Author: YAMADA Taro <hogehoge@example.com>
Date: Thu Jan 23 01:23:45 2025 +0900
1 file changed, 2 insertions(+), 2 deletions(-)
$ git show HEAD --name-status --pretty=fuller
commit 110f2d52243d3bdf9a4429d28189453d57a2c9ed (HEAD)
Author: YAMADA Taro <hogehoge@example.com>
AuthorDate: Thu Jan 23 01:23:45 2025 +0900
Commit: NAGAYASU Shinya <nagayasu_shinya@yahoo.co.jp>
CommitDate: Thu Mar 19 23:56:57 2026 +0900
test: Fix remote_helper test error for long $PWD
Use relative Unix socket paths in tests to avoid overflowing the Unix
socket name length limit when $PWD is long.
Fixes #1697.
M test/suites/remote_helper.bash
|
これは GIT_COMMITTER_NAME GIT_COMMITTER_EMAIL GIT_COMMITTER_DATE を併用すれば解決できます。
いまの Committer の値をこれらの環境変数に設定することで同じ設定で上書きします。
下記の例では git show --pretty='format:%cn' のようにしてそれらの値を取得しています。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
| $ git show HEAD --name-status --pretty=fuller
commit 190066b4eb8b7a1b1cda2fecdf5a6b70a1da703b (HEAD)
Author: Joel Rosdahl <joel@rosdahl.net>
AuthorDate: Thu Mar 12 08:31:19 2026 +0100
Commit: Joel Rosdahl <joel@rosdahl.net>
CommitDate: Thu Mar 12 08:44:12 2026 +0100
test: Fix remote_helper test error for long $PWD
Use relative Unix socket paths in tests to avoid overflowing the Unix
socket name length limit when $PWD is long.
Fixes #1697.
M test/suites/remote_helper.bash
$ GIT_COMMITTER_NAME="$( git show --pretty='format:%cn' | head -n1)" \
GIT_COMMITTER_EMAIL="$(git show --pretty='format:%ce' | head -n1)" \
GIT_COMMITTER_DATE="$( git show --pretty='format:%cd' | head -n1)" \
git commit --amend --no-edit --author="YAMADA Taro <hogehoge@example.com>" --date="2025-01-23T01:23:45+09:00"
[detached HEAD 94b4981] test: Fix remote_helper test error for long $PWD
Author: YAMADA Taro <hogehoge@example.com>
Date: Thu Jan 23 01:23:45 2025 +0900
1 file changed, 2 insertions(+), 2 deletions(-)
$ git show HEAD --name-status --pretty=fuller
commit 94b498124ff1456eb753ed3537920e3e8e218ff5 (HEAD)
Author: YAMADA Taro <hogehoge@example.com>
AuthorDate: Thu Jan 23 01:23:45 2025 +0900
Commit: Joel Rosdahl <joel@rosdahl.net>
CommitDate: Thu Mar 12 08:44:12 2026 +0100
test: Fix remote_helper test error for long $PWD
Use relative Unix socket paths in tests to avoid overflowing the Unix
socket name length limit when $PWD is long.
Fixes #1697.
M test/suites/remote_helper.bash
|
もっと昔のコミットの修正#
今までの例は最新のコミットの修正でした。2つ以上前のコミットも変更したいこともあるかもしれません。
その場合は git rebase -i を利用します。
例として下記の3つのコミットを修正します。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
| $ git log --pretty=fuller --name-status
commit 190066b4eb8b7a1b1cda2fecdf5a6b70a1da703b (HEAD)
Author: Joel Rosdahl <joel@rosdahl.net>
AuthorDate: Thu Mar 12 08:31:19 2026 +0100
Commit: Joel Rosdahl <joel@rosdahl.net>
CommitDate: Thu Mar 12 08:44:12 2026 +0100
test: Fix remote_helper test error for long $PWD
Use relative Unix socket paths in tests to avoid overflowing the Unix
socket name length limit when $PWD is long.
Fixes #1697.
M test/suites/remote_helper.bash
commit edc01c08f0f5e7e1808cc80dccfece9c59469368
Author: Joel Rosdahl <joel@rosdahl.net>
AuthorDate: Thu Mar 12 08:24:32 2026 +0100
Commit: Joel Rosdahl <joel@rosdahl.net>
CommitDate: Thu Mar 12 08:24:32 2026 +0100
chore: Improve log messages for Unix socket connect failure
Related to #1697.
M test/storage/helper/main.cpp
commit e7bf8e7fea2460226ad80ab08d2b0ece3b1bc632
Author: Joel Rosdahl <joel@rosdahl.net>
AuthorDate: Wed Mar 11 21:21:44 2026 +0100
Commit: Joel Rosdahl <joel@rosdahl.net>
CommitDate: Wed Mar 11 21:21:44 2026 +0100
ci: Add macOS 15/26 builds
Also bump Xcode version for macOS 14.
M .github/workflows/build.yaml
|
まず git rebase -i にて3つのコミットを編集できるようにします。
変更したいコミットを edit に設定します。このときのコミットIDは後で必要になるのでメモしておいてください。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
| pick 801d828 chore: Improve log messages for Unix socket connect failure
edit e7bf8e7 ci: Add macOS 15/26 builds
edit edc01c0 chore: Improve log messages for Unix socket connect failure
edit 190066b test: Fix remote_helper test error for long $PWD
# Rebase dd994d2..190066b onto dd994d2 (4 commands)
#
# Commands:
# p, pick <commit> = use commit
# r, reword <commit> = use commit, but edit the commit message
# e, edit <commit> = use commit, but stop for amending
# s, squash <commit> = use commit, but meld into previous commit
# f, fixup [-C | -c] <commit> = like "squash" but keep only the previous
# commit's log message, unless -C is used, in which case
# keep only this commit's message; -c is same as -C but
# opens the editor
# x, exec <command> = run command (the rest of the line) using shell
# b, break = stop here (continue rebase later with 'git rebase --continue')
# d, drop <commit> = remove commit
# l, label <label> = label current HEAD with a name
# t, reset <label> = reset HEAD to a label
# m, merge [-C <commit> | -c <commit>] <label> [# <oneline>]
# create a merge commit using the original merge commit's
# message (or the oneline, if no original merge commit was
# specified); use -c <commit> to reword the commit message
# u, update-ref <ref> = track a placeholder for the <ref> to be updated
# to this position in the new commits. The <ref> is
# updated at the end of the rebase
#
# These lines can be re-ordered; they are executed from top to bottom.
#
# If you remove a line here THAT COMMIT WILL BE LOST.
#
# However, if you remove everything, the rebase will be aborted.
|
古いコミットから1つずつ修正していきます。
いま時点でrebaseする3つのコミットの中で1番古いコミットをHEADが指しているはずです。
1
2
3
4
5
6
7
8
9
10
11
12
| $ git show --pretty=fuller --name-status
commit e7bf8e7fea2460226ad80ab08d2b0ece3b1bc632 (HEAD)
Author: Joel Rosdahl <joel@rosdahl.net>
AuthorDate: Wed Mar 11 21:21:44 2026 +0100
Commit: Joel Rosdahl <joel@rosdahl.net>
CommitDate: Wed Mar 11 21:21:44 2026 +0100
ci: Add macOS 15/26 builds
Also bump Xcode version for macOS 14.
M .github/workflows/build.yaml
|
このコミットをこれまで説明してきた方法で修正します。
ここでもコミットを修正するとCommitterが今現在のGitアカウントに更新されてしまうので、
下記の例ではもとのGit コミットID(e7bf8e7)のCommitterを指定しています。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
| $ GIT_COMMITTER_NAME="$( git show e7bf8e7 --pretty='format:%cn' | head -n1)" \
GIT_COMMITTER_EMAIL="$(git show e7bf8e7 --pretty='format:%ce' | head -n1)" \
GIT_COMMITTER_DATE="$( git show e7bf8e7 --pretty='format:%cd' | head -n1)" \
git commit --amend --no-edit --author="YAMADA Taro <hogehoge@example.com>"
[detached HEAD 545fa368] ci: Add macOS 15/26 builds
Author: YAMADA Taro <hogehoge@example.com>
Date: Wed Mar 11 21:21:44 2026 +0100
1 file changed, 10 insertions(+), 1 deletion(-)
$ git show --pretty=fuller --name-status
commit 545fa36809d77b5d7ab76047aef12a670d6156c4 (HEAD)
Author: YAMADA Taro <hogehoge@example.com>
AuthorDate: Wed Mar 11 21:21:44 2026 +0100
Commit: Joel Rosdahl <joel@rosdahl.net>
CommitDate: Wed Mar 11 21:21:44 2026 +0100
ci: Add macOS 15/26 builds
Also bump Xcode version for macOS 14.
M .github/workflows/build.yaml
|
コミットの修正が完了したら次のコミットへ進みます。
あとは繰り返しです。ここでもCommitterが今現在のGitアカウントに更新されてしまっているので、
明示的に rebase前のコミットID(edc01c0)の情報で上書きが必要です。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
| $ GIT_COMMITTER_NAME="$( git show edc01c0 --pretty='format:%cn' | head -n1)" \
GIT_COMMITTER_EMAIL="$(git show edc01c0 --pretty='format:%ce' | head -n1)" \
GIT_COMMITTER_DATE="$( git show edc01c0 --pretty='format:%cd' | head -n1)" \
git commit --amend --no-edit --author="YAMADA Taro <hogehoge@example.com>"
[detached HEAD 87f9ee82] chore: Improve log messages for Unix socket connect failure
Author: YAMADA Taro <hogehoge@example.com>
Date: Thu Mar 12 08:24:32 2026 +0100
1 file changed, 4 insertions(+), 1 deletion(-)
$ git show --pretty=fuller --name-status
commit 87f9ee826c8b5a97503dba2d8a1f44e4174b2468 (HEAD)
Author: YAMADA Taro <hogehoge@example.com>
AuthorDate: Thu Mar 12 08:24:32 2026 +0100
Commit: Joel Rosdahl <joel@rosdahl.net>
CommitDate: Thu Mar 12 08:24:32 2026 +0100
chore: Improve log messages for Unix socket connect failure
Related to #1697.
M test/storage/helper/main.cpp
|
すべての edit が終わり Successfully rebased and updated refs/heads/... と表示されれば完了です。
最終的なログを確認すると、指定したコミットのAuthorが変更されているはずです。
最終的には下記のようになります。Authorを YAMADA Taroさんに変更できました。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
| git log --name-status --pretty=fuller
commit 1cc0e6a49abd43a1949f3ad260c20ba54613775d (HEAD)
Author: YAMADA Taro <hogehoge@example.com>
AuthorDate: Thu Mar 12 08:31:19 2026 +0100
Commit: Joel Rosdahl <joel@rosdahl.net>
CommitDate: Thu Mar 12 08:44:12 2026 +0100
test: Fix remote_helper test error for long $PWD
Use relative Unix socket paths in tests to avoid overflowing the Unix
socket name length limit when $PWD is long.
Fixes #1697.
M test/suites/remote_helper.bash
commit 87f9ee826c8b5a97503dba2d8a1f44e4174b2468
Author: YAMADA Taro <hogehoge@example.com>
AuthorDate: Thu Mar 12 08:24:32 2026 +0100
Commit: Joel Rosdahl <joel@rosdahl.net>
CommitDate: Thu Mar 12 08:24:32 2026 +0100
chore: Improve log messages for Unix socket connect failure
Related to #1697.
M test/storage/helper/main.cpp
commit 545fa36809d77b5d7ab76047aef12a670d6156c4
Author: YAMADA Taro <hogehoge@example.com>
AuthorDate: Wed Mar 11 21:21:44 2026 +0100
Commit: Joel Rosdahl <joel@rosdahl.net>
CommitDate: Wed Mar 11 21:21:44 2026 +0100
ci: Add macOS 15/26 builds
Also bump Xcode version for macOS 14.
M .github/workflows/build.yaml
|
git filter-repo#
2, 3 個程度のコミットの修正なら git commit --amend でもいいと思いますが、数が多くなると非効率です。
そこで、さらに強力なツールとしてgit filter-repoがあります。
注意点#
このツールには注意点があるので先にその点を述べておきます。
このツールを実行すると下記のようにリモートのoriginを削除してしまいます。これは歴史改変したコミットを意図せずpushしないようにするための措置でしょう。
1
2
3
| NOTICE: Removing 'origin' remote; see 'Why is my origin removed?'
in the manual if you want to push back there.
(was https://github.com/your-username/your-repository.git)
|
あらかじめremoteの情報をメモしておき、git remote add で再度リモートを追加すればよいでしょう。
1
2
3
| $ git remote -v
origin https://github.com/ccache/ccache.git (fetch)
origin https://github.com/ccache/ccache.git (push)
|
1
| git add remote origin https://github.com/ccache/ccache.git
|
使い方#
さて、ツールの使い方に戻ります。
まずは wget で Python のコードをダウンロードします。
1
| wget https://raw.githubusercontent.com/newren/git-filter-repo/refs/heads/main/git-filter-repo
|
下記にAuthorを変更する例を示します。git commit --amendのときと違ってCommitterは変更されません。
また、--refs HEAD^..HEAD のようにコミットを明示しないと過去すべての履歴を修正してしまうので注意してください。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
| DT='2025-01-23T01:23:45+09:00' && python3 git-filter-repo --commit-callback "commit.author_name = b'YAMADA Taro'; commit.author_email = b'hogehoge@example.com'; commit.author_date = b'$(date -d $DT +%s) $(date -d $DT +%z)'" --force --refs HEAD^..HEAD
Parsed 1 commits
New history written in 0.02 seconds...
HEAD is now at 94b49812 test: Fix remote_helper test error for long $PWD
Completely finished after 0.03 seconds.
$ git show --pretty=fuller --name-status
commit 94b498124ff1456eb753ed3537920e3e8e218ff5 (HEAD)
Author: YAMADA Taro <hogehoge@example.com>
AuthorDate: Thu Jan 23 01:23:45 2025 +0900
Commit: Joel Rosdahl <joel@rosdahl.net>
CommitDate: Thu Mar 12 08:44:12 2026 +0100
test: Fix remote_helper test error for long $PWD
Use relative Unix socket paths in tests to avoid overflowing the Unix
socket name length limit when $PWD is long.
Fixes #1697.
M test/suites/remote_helper.bash
|
ここで、時刻指定はUNIX時間(エポック秒)とタイムゾーンで指定する必要があります。
ISO 8601から変換するには下記のようにdateを使えばできます。
1
2
3
4
| $ date -d 2025-01-23T03:23:45+09:00 +%s
1737570225
$ date -d 2025-01-23T03:23:45+09:00 +%z
+0900
|
複数のコミットを修正するのもかんたんです。git commit --amendのときのように git rebase -iで何回もコマンドを実行しなくてよいので楽ですね。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
| $ python3 git-filter-repo --commit-callback "commit.author_name = b'YAMADA Taro'; commit.author_email = b'hogehoge@example.com'" --force --refs HEAD~3..HEAD
Parsed 3 commits
New history written in 0.02 seconds...
HEAD is now at 1cc0e6a4 test: Fix remote_helper test error for long $PWD
Completely finished after 0.03 seconds.
$ git log --name-status --pretty=fuller
commit 1cc0e6a49abd43a1949f3ad260c20ba54613775d (HEAD)
Author: YAMADA Taro <hogehoge@example.com>
AuthorDate: Thu Mar 12 08:31:19 2026 +0100
Commit: Joel Rosdahl <joel@rosdahl.net>
CommitDate: Thu Mar 12 08:44:12 2026 +0100
test: Fix remote_helper test error for long $PWD
Use relative Unix socket paths in tests to avoid overflowing the Unix
socket name length limit when $PWD is long.
Fixes #1697.
M test/suites/remote_helper.bash
commit 87f9ee826c8b5a97503dba2d8a1f44e4174b2468
Author: YAMADA Taro <hogehoge@example.com>
AuthorDate: Thu Mar 12 08:24:32 2026 +0100
Commit: Joel Rosdahl <joel@rosdahl.net>
CommitDate: Thu Mar 12 08:24:32 2026 +0100
chore: Improve log messages for Unix socket connect failure
Related to #1697.
M test/storage/helper/main.cpp
commit 545fa36809d77b5d7ab76047aef12a670d6156c4
Author: YAMADA Taro <hogehoge@example.com>
AuthorDate: Wed Mar 11 21:21:44 2026 +0100
Commit: Joel Rosdahl <joel@rosdahl.net>
CommitDate: Wed Mar 11 21:21:44 2026 +0100
ci: Add macOS 15/26 builds
Also bump Xcode version for macOS 14.
M .github/workflows/build.yaml
|
Committerを変更するときも同様です。commit.committer_name commit.committer_email commit.committer_date を使用します。
指定方法はAuthorのときと同じです。
まとめ#
Gitの禁じ手である、Committer, Author およびその時刻の改変の方法を説明しました。
めったに使うことはないですが、使う際は慎重に実施しましょう。