Git fatal: unable to auto-detect email address

问题描述

废话较多,看方法的直接跳转到最后。按照廖雪峰的Git教程在Windowns上配置git,并编辑文件进行提交时,出现以下错误提示:

** Please tell me who you are.

Run
  git config --global user.email "[email protected]"
  git config --global user.name "Your Name"

to set your account's default identity.
Omit --global to set the identity only in this repository.

fatal: unable to auto-detect email address (got '[email protected](none)')

意思是说你在创建本地仓库时未定义用户名和邮箱,此时再按照错误提示,利用

git config --global user.name "follow"
git config --global user.email "[email protected]"

进行用户名和密码配置发现并不管用。百度到的方法全是说:

找到工程目录的.git文件夹,打开之后找到config文件,在最后边加上一句话
[user]
 email=your email
 name=your name

这种方法我没有实验,因为在对Git研究不够深的情况下,贸然进行修改配置文件的操作,我是拒绝的。

还有说配置完

git config --global user.name "follow"
git config --global user.email "[email protected]"

再跟上一句

git config --local -l

追加的指令只是用来看本地配置的,根本不能解决问题。因此回顾创建仓库的步骤,发现是建库初期缺失了一个步骤。

问题解决

按照教程中所说:

Git fatal: unable to auto-detect email address

在安装完Git时就应该定义用户名和密码,如果忘记了,等创建完仓库后重新设置就会出现上述所述问题。

本人的解决方法:

1、删除本地仓库;
2、配置用户名和密码
	git config --global user.name "follow"
	git config --global user.email "[email protected]"
3、重新创建本地仓库,并编辑提交文件:
	mkdir learngit
	cd learngit
	git init
	vi readme.txt
	git add readme.txt
	git commit -m "add a file"

当然此办法治标不治本,具体的原因我也不是很清楚,但是暂时解决了问题,待进一步学习后再研究合适的解决办法。