恕我直言,解决此错误的正确方法是配置全局git config文件。
为此,请运行以下命令: 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.email设置告诉git您是谁,因此后续git commit命令不会抱怨,*** Please tell me who you are.
很多时候,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命令并浏览我认为可行的事情之前,对我的项目文件进行了备份-多次节省了培根。