必须配置 user.name 和 user.email 才能提交,运行 git config --global user.name "Your Name" 与 git config --global user.email "you@example.com" 并重启 VSCode 即可解决。

Git 提交报错 “Author identity unknown” 怎么办
这不是 VSCode 的 bug,而是 Git 本身拒绝提交——它连最基本的作者身份都没拿到。只要 user.name 或 user.email 缺一个,git commit 就直接中止,VSCode 只是把错误原样抛出来。常见于新装 Git、重装系统、或用 Homebrew/Scoop 安装后没手动初始化配置。
必须用终端设,别在 VSCode 设置里找
VSCode 的设置界面里搜 “git user” 是无效的。它的 Git 集成完全依赖系统 PATH 中的 git 命令,读取的是 Git 自己的配置文件(比如 C:\Users\{user}\.gitconfig 或 ~/.gitconfig),不是编辑器 UI 设置项。
- 打开 VSCode 内置 Terminal(
Ctrl+`)或系统终端 - 运行这两条命令(注意空格和双引号):
git config --global user.name "Your Name"<br>git config --global user.email "you@example.com"
- 验证是否生效:
git config --global user.name<br>git config --global user.email
两个都得有输出,缺一不可 - 改完重启 VSCode(或执行
Ctrl+Shift+P→Developer: Reload Window)
邮箱填错了,历史提交还能改吗
修改 user.email 只影响后续新提交,不会自动修正已有 commit。刚提交一两条就发现错了,立刻用 git commit --amend --author="Name <email@domain.com>" 覆盖;但一旦 git push 到远程,再改就得走 git rebase -i + git commit --amend 流程,强制推送(git push --force-with-lease)可能打断协作者的本地分支,非必要不建议。
为什么 GitHub 邮箱和这里要一致
user.email 不强制要求是真实邮箱,写 me@localhost 也能过 Git 校验,但 GitHub/GitLab 是靠这个字段匹配用户头像和贡献统计的。如果填错,提交记录会显示为“unverified”或不计入个人 contribution 图——不是功能问题,是协作可见性问题。本地配置和平台注册邮箱不一致,是日常排查提交归属最常漏看的一环。


















