
スポンサーリンク
Gitコミット操作(エラー)
Gitのコミットをしようとすると以下エラーが発生した。
$ git commit -m "update"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: empty ident name (for <>) not allowed
エラーの原因
このエラーは、Gitのコミットを行おうとした際に、ユーザー情報(名前とメールアドレス)が設定されていないため発生しています。
エラーの対応方法
GitBashでコマンドを実行して、ユーザー情報を設定してください。
ユーザ情報確認
git config --global
コマンドでユーザ情報を確認します。
初期設定は未設定であることが考えられるため、何も出てこない想定です。
メール情報
メール情報はuser.email
を指定して確認します。
git config --global user.email
※結果が出力されない。
ユーザ名
ユーザ名はuser.name
を指定して確認します。
git config --global user.name
※結果が出力されない。
ユーザ名設定
ユーザ名(user.name)の設定は以下コマンドを実行します。(Your Name
は実施者の名前に置き換えてください。)
git config --global user.name "Your Name"
メール情報設定
メール情報(user.enail)の設定は以下コマンドを実行します。(you@example.com
は実施者のEメールアドレスに置き換えてください。)
git config --global user.email "you@example.com"
設定後確認
ユーザ名とメール情報が指定した値で設定されていることを確認します。
ユーザ名の設定後確認
$ git config --global user.nameYour Name→設定したユーザ名が表示される
メール情報の設定後確認
$ git config --global user.emailyou@example.com→設定したEメールアドレスが表示される
対応後Gitコミットの動作確認
ユーザ情報(ユーザ名・Eメール)の設定後、Gitコミットを再度実行します。
以下の通り、エラーが発生しなくなることを確認できました。
$ git commit -m "update"[main 69bf1fa] update 1 file changed, 4 insertions(+) $ git pushEnumerating objects: 11, done.Counting objects: 100% (11/11), done.Delta compression using up to 14 threadsCompressing objects: 100% (5/5), done.Writing objects: 100% (6/6), 491 bytes | 245.00 KiB/s, done.Total 6 (delta 4), reused 0 (delta 0), pack-reused 0 (from 0)remote: Resolving deltas: 100% (4/4), completed with 4 local objects.To https://github.com/XXX/XXX.git 6c540dc..69bf1fa main -> main
以上で本記事の解説を終わります。
よいITライフを!