恕我冒昧,解决这个错误的正确方法是配置你的全局git配置文件。
执行以下命令:git config——global -e
将出现一个编辑器,您可以在其中插入默认的git配置。
以下是一些例子:
[user]
name = your_username
email = your_username@users.noreply.github.com
[alias]
# BASIC
st = status
ci = commit
br = branch
co = checkout
df = diff
具体操作请参见自定义Git - Git配置
当你看到这样的命令,git config…
$ git config --global core.whitespace \
trailing-space,space-before-tab,indent-with-non-tab
... 你可以把它放到你的全局git配置文件中:
[core]
whitespace = space-before-tab,-indent-with-non-tab,trailing-space
对于一次性配置,你可以使用git config——global user.name 'your_username'
如果你没有全局设置你的git配置,你需要为你在本地使用的每一个git repo这样做。
user.name和user.name。email设置告诉git你是谁,所以后续git提交命令不会报错,***请告诉我你是谁。
很多时候,git建议您运行的命令并不是您应该运行的命令。这一次,建议的命令还不错:
$ git commit -m 'first commit'
*** Please tell me who you are.
Run
git config --global user.email "you@example.com"
git config --global user.name "Your Name"
提示:在我非常熟悉git之前,在运行建议的git命令和探索我认为可行的东西之前,对我的项目文件进行备份,在很多情况下挽救了我的生命。