Github 初次使用 commit命令提交失败
程序员文章站
2024-01-12 16:22:04
...
在第一次练习使用时,在使用git commit命令时会执行失败,比如我在首次使用时先使用git init命令初始化本地仓库,然后要用git commit -m "Initial commit"命令提交,但是提示失败:
*** 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: empty ident name (for (null)>) not allowed during executing
git -c core.quotepath=false commit -m "Initial commit" --
命令执行失败的原因是没有在本地设置用户名和邮箱,在命令行设置一下即可:
git config –global user.email “[email protected]”、
git config –global user.name “Your Nam”, 然然后重新用git commit -m “Initial commit”命令提交。
上面的方法配置的是全局的用户名和邮箱!就是说如果没有单独为项目配置,那提交的所有项目全部都是这个名字和邮箱!不管是公司项目还是github,还是码云!很蛋疼有木有,当码云提交记录上出现我名字的时候我都惊呆了!
单独为项目配置的方法(全局和单独配置都存在的时候会默认使用项目单独配置的):
1.打开项目所在目录,找到隐藏的.git文件夹。注意这个文件夹是隐藏的,显示隐藏出来就行。
2.打开文件夹里的config文件,推荐用nodepad++打开。
3.添加这三行到文件:
[user]
name = XXX(自己的名称)
email = XXXX(邮箱)
当然也可以通过命令行的方式,只需要在 .git 文件夹下。 例如执行如下命令:
git config --global user.email "[email protected]"
git config --global user.name "Your Name"
设置完成后,重新启动GIT,提交,成功!
上一篇: 初识hexo 01:hexo基础命令以及推到Github
下一篇: HDU 1297