obsidian/笔记文件/2.笔记/git使用commit命令后显示Author identity unknown的解决方法.md
2025-03-26 00:02:56 +08:00

44 lines
1.2 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#杂七杂八常识
当我们在git commit -m 'xxx'时出现
![[Pasted image 20230420222722.png]]
命令执行失败的原因是没有在本地设置用户名和邮箱,在命令行设置一下即可:
``` shell
git config global user.email 'you@example.com'
git config global user.name 'Your name'
```
上面的方法配置的是全局的用户名和邮箱!就是说如果没有单独为项目配置,那提交的所有项目全部都是这个名字和邮箱!
单独为项目配置的方法(全局和单独配置都存在的时候会默认使用项目单独配置的)
打开项目所在目录,找到隐藏的.git文件夹。注意这个文件夹是隐藏的显示隐藏出来就行。
打开文件夹里的config文件推荐用nodepad++打开。
添加这三行到文件:
``` shell
[user]
name = XXX(自己的名称)
email = XXXX(邮箱)
```
举例说明:
![[Pasted image 20230420222859.png]]
当然也可以通过命令行的方式,只需要在 .git 文件夹下。 例如执行如下命令:
``` shell
git config global user.email 'you@example.com'
git config global user.name 'Your name'
```
这样就设置成功啦!