.Dev.Record

#621b647d53166

Gitでコミット時に「unable to auto-detect email address」のエラーが出た際の解消法

2022.02.27

test

開発中にGITでコミットをしようとしたらfatal: unable to auto-detect email address (got 'xxxxxxxxxxxx')のエラーが出てコミットができなかった。

エラーの原因と解消法

下記がエラー時のログ全文。

error.log

1Author identity unknown
2
3*** Please tell me who you are.
4
5Run
6
7  git config --global user.email "you@example.com"
8  git config --global user.name "Your Name"
9
10to set your account's default identity.
11Omit --global to set the identity only in this repository.
12
13fatal: unable to auto-detect email address (got 'xxxxxxxxxxxxx')

結論としては、GITにメールアドレスを設定していなかったことが原因。

ログ内にあるように下記でメールアドレスを設定すればOK。(ついでにユーザー名も設定する)

set-mail

1git config --global user.email "<メールアドレス>"
2git config --global user.name "<ユーザー名>"

正常に登録できたかを確認するには、git config -lで登録した情報が下記のように表示されているかを確認する。

conf-info

1❯ git config -l
2...
3user.email=<登録したメールアドレス>
4user.name=<登録したユーザー名>

再度git commitすれば無事にコミットが完了する。

今回開発時に急に上記のエラーが起きた。今までもメールアドレスは登録してなかったのに何故急にこのようになったのかは不明。

.Dev.Record