git遇到的问题
记录一下我在使用git时遇到的问题
一、pathspec 'apitestdata.sql' did not match any files
当使用git add 命令添加文件时出现 pathspec 'apitestdata.sql' did not match any files 报错,表示找不到文件

原因是未切换到文件所在目录。
这时只要使用 cd 命令切换到文件所在目录,再 git add 文件即可

二、git 提交报错
使用 git commit 时出现下面的报错信息
Commit failed - exit code 128 received, with output: '*** Please tell me who you are.
Run
git config --global user.email "you@example.com"
git config --global user.name "Your Name"
一般情况下只需要在 Git Bash中输入下面这两条命令就可以
git config --global user.email "you@example.com"
git config --global user.name "Your Name"
但有时候不管用,这个时候就需要修改git的配置 文件,告诉git你的身份
进入你git clone下来的仓库,打开 .git 目录下的config文件,在最后加上
[user]
name = ${你的 git 用户名}
email = ${你的 git 邮箱}
三、failed to push some refs to "XXX"
在 git push 时遇到 failed to push some refs to "XXX"问题,一般是因为本地的版本落后于远程仓库,
只要在 git add 之前 git pull 一下就可以了
四、使用https克隆下来的仓库,每次 git push 都要输入用户名和密码
(1)方法一是将 https 的拉取方式换为 ssh方式
1、git remote -v
查看仓库的克隆地址

2、git remote rm origin
删除 https 方式
3、git remote add origin [git 地址]
换成 ssh 克隆方式
(2)方法二是修改 git 的配置文件
执行命令 git config --global credential.helper store
git pull 输入邮箱和密码,以后再就不需要了
或者直接打开 .git 目录下的config 文件,在最后加上
[credential]
helper = store

浙公网安备 33010602011771号