上传项目到github时出现如下错误:
报错1
报错2
原因:缺少两句关键代码
git config --global user.email “邮箱地址”
git config --global user.name "用户名"
注意:
- 是邮箱地址@前面那个,
- 一般需要运行两遍才能成功
- 代码:第一遍 (最后一行 +f 代表强制上传)
- git init
- git add .
- git commit -m "first commit"
- git config --global user.email "xxx"
- git config user.name "xxx"
- git remote add origin https://xxx.git
- git push -u origin master
此时可能会报错,因此需要执行第二遍。
第二遍通常会成功,可能需要输入github注册时候的账户和密码,注意账户是不带@的!
- 代码:第二遍
- git init
- git add .
- git commit -m "first commit"
- git remote add origin https://xxx.git
- git push -u origin master