Git commit できない(Author identity unknown / who you are)
user.name と user.email が未設定だと commit が「Author identity unknown」で失敗する。
global もしくはリポジトリ単位で名前とメールを設定すればコミットできる。
公開: 更新:
git commit -m "init" … fatal: no email was given and auto-detection is disabled
git commit -m "init" [main (root-commit) b3bc41b] init 1 file changed, 1 insertion(+) create mode 100644 f.txt
2026-08-05 に alpine/git で実際に打って取った出力。検証環境の詳細
要約
git commit が次のように止まるのは、コミットの作者として記録する名前とメールアドレスが設定されていないためだ。
git は誰がコミットしたかを必ず記録するので、user.name と user.email の両方が決まるまでコミットを作れない。
global に一度設定すれば、以降すべてのリポジトリで使い回せる。
*** Please tell me who you are.
Run
git config --global user.email "you@example.com"
git config --global user.name "Your Name"
to set your account's default identity.
fatal: unable to auto-detect email address (got 'user@host.(none)')実行例
alpine/git 環境で上記の手順を動かすと、設定前の git commit は終了コード 128 で失敗した。git config --global で user.name と user.email を設定した後のコミットは、終了コード 0 で成功した。
$ git commit -m "init"
Author identity unknown
*** Please tell me who you are.
Run
git config --global user.email "you@example.com"
git config --global user.name "Your Name"
to set your account's default identity.
Omit --global to set the identity only in this repository.
fatal: no email was given and auto-detection is disabled
$ echo $?
128$ git config --global user.name "Your Name"$ git config --global user.email "you@example.com"$ git commit -m "init"
[main (root-commit) b3bc41b] init
1 file changed, 1 insertion(+)
create mode 100644 f.txt
$ echo $?
0$ git config --list --show-origin | grep user
file:/tmp/tmp.LJNjiM/home/.gitconfig user.useconfigonly=true
file:/tmp/tmp.LJNjiM/home/.gitconfig user.name=Your Name
file:/tmp/tmp.LJNjiM/home/.gitconfig user.email=you@example.com今回の再現では、未設定状態を確実に作るため、事前に git config --global user.useConfigOnly true を設定している。
そのため commit の失敗メッセージは、冒頭に挙げた fatal: unable to auto-detect email address (got 'user@host.(none)') ではなく fatal: no email was given and auto-detection is disabled になっている。
上の --show-origin の出力に user.useconfigonly=true が含まれるのも、この設定によるものだ。
自動検出が有効な通常の環境では冒頭のメッセージが表示されるが、原因(user.name / user.email の未設定)と解決策はどちらの場合も同じである。
$ git log --oneline
b3bc41b init— 2026-08-05 時点の出力
検証環境2026-08-05 検証
- 検証日
- 実行環境
alpine/git
この記事の「実行例」は、上記の環境で実際にコマンドを実行して得られた出力をそのまま掲載しています。 再現手順はリポジトリの検証スクリプトとして管理し、定期的に再実行して出力を更新しています。
解決策
1. global に名前とメールを設定する
最も一般的なのは、マシン全体で使う値を global に設定する方法である。
git config --global user.name "Your Name"
git config --global user.email "you@example.com"設定後にもう一度 git commit を実行すれば通る。
GitHub に公開したくない場合は、GitHub が提供する noreply メール(...@users.noreply.github.com)を使うとアドレスを隠せる。
2. リポジトリ単位で別の値を使う
仕事用と個人用でメールを分けたいときは、そのリポジトリ内で --global を付けずに実行する。
ローカル設定は global より優先される。
cd path/to/repo
git config user.email "work@example.com"3. 反映を確認する
意図した値になっているかは次のコマンドで確認できる。
global とローカルのどちらが効いているかも分かる。
git config --list --show-origin | grep user
git config user.emailよくある原因
- 新しい環境で一度も設定していない。
OS を入れ替えたときや、別マシン、新しいユーザーで起きる。 - リポジトリ単位の設定が空になっている。
global には設定があるのに、このリポジトリのローカル設定が優先されて空になっている。 .gitconfigが無い。
CI のコンテナや最小構成の環境では、ホーム配下の設定ファイルが存在しない。- メールの自動検出に失敗している。
ホスト名から推測したメールが無効で、unable to auto-detect email addressになる。