git commit asking for who you are

Max*_*axG 3 git git-commit

I ran into below error message while trying to make some commits.

*** Please tell me who you are.

    Run

      git config --global user.email "you@example.com"
      git config --global user.name "Your Name"
Run Code Online (Sandbox Code Playgroud)

可以通过输入如图所示的指示命令来解决该问题。我只是想知道为什么会出现这样的消息?我已经使用 git 一段时间了,通常它只会提交并添加文件,而不会出现任何这样的消息。

Ren*_*hle 5

默认情况下,git 会在不同的地方查找全局配置文件。

~/.gitconfig或者~/.config/git/config之后它会调查.git/config您的项目文件夹。通常,您将全局设置保存在前两个配置文件之一中。如果您切换用户或删除该文件,您的全局设置将丢失。您可以在 git 配置中阅读更多信息。

https://git-scm.com/book/tr/v2/Customizing-Git-Git-Configuration