Git上传失败问题

git推送失败

git push -u origin master 错误提示

1
2
3
4
5
6
7
8
9
$ git push -u origin master
Username for 'https://github.com': xxx
To https://github.com/xxx.git
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'https://github.com/xxx.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

错误分析

GitHub远程仓库中的README.md文件不在本地仓库中。

解决方案1

强制推送命令

1
git push -f origin master

解决方案2

代码合并

1
2
git pull --rebase origin master
git push origin master

git提交失败

git:>running pre-commit hook:lint-staged

img

错误分析

这句话的意思,大概是有一个钩子,提交前检查项目代码的规范,eslint的检查。提交失败的原因:项目中error过多,导致检测未通过,提交失败。

解决方案

一、不进行检查

那就是删除掉pre-commit hook,具体在项目文件夹.git\hooks目录下,找到文件pre-commit

img

二、再次提交成功

这个方法比较简单粗暴,自然也是存在一些弊端,代码不严谨,不能符合Eslint标准。也有其他的解决方式,在配置文件中,不需要使用eslint时,把lintOnSave设为false即可。


 

评论

Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×