当前位置:   article > 正文

git使用中的疑难杂症(踩坑合集)_does not have a commit checked out fatal: adding f

does not have a commit checked out fatal: adding files failed

一、 error: ‘my_project/’ does not have a commit checked out fatal: adding files failed

1、情景再现:

git add 提交文件到暂存区时报错

error: 'my_project/' does not have a commit checked out   fatal:
adding files failed
  • 1
  • 2

2、原因:

提交项目子目录中有.git文件(可能是隐藏状态),显示隐藏文件即可
在这里插入图片描述

3、解决办法:

找到 .git 文件夹,删除!

二、 src refspec main does not match any

1、情景再现:

git push -u origin main 提交项目到远程仓库时报错

$ ahua win64 ~/Desktop/vue (master)
$ git push -u origin main
error: src refspec main does not match any
  • 1
  • 2
  • 3

2、原因:

提交到远程仓库中的分支和本地的仓库的分支不一样,可以看到上面代码块中的分支是master(现在github主分支是main)

3、解决办法:

修改本地分支名为main即可

git branch -m oldBranchName newBranchName
  • 1

三、warning: LF will be replaced by CRLF in node/node_project.The file will have its original line endings in your working directory

1、情景再现:

git add添加文件到暂存区时警告

warning: LF will be replaced by CRLF in node/node-project.
The file will have its original line endings in your working directory
  • 1
  • 2

2、原因:

这是因为在windows和unix下的换行符不一样,git bush是unix风格设计的,虽然git默认会自动转换,但是有时会出问题

3、解决办法:

禁止自动转换

git config --global core.autocrlf false
  • 1

四、 ! [rejected] main -> main (fetch first) error: failed to push some refs to ‘https://github.com/xxxxxx’

1、情景再现:

git push origin main 提交代码到远程仓库时报错

 ! [rejected]        main -> main (fetch first)
error: failed to push some refs to 'https://github.com/xxxxxx'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8

2、原因:

远程仓库中的代码比本地仓库中的新(存在本地仓库没有的文件)

3、解决办法:

将远程仓库中的代码合并到本地即可

git pull --rebase origin main
  • 1

五、curl 28 OpenSSL SSL_read: Connection was aborted, errno 10053

1、情景再现

 curl 28 OpenSSL SSL_read: Connection was aborted, errno 10053
fatal: error reading section header 'shallow-info'
  • 1
  • 2

2、原因

可能是你使用了科学上网工具

3、解决办法

使git忽略ssl证书错误

git config http.sslVerify "false"
  • 1

六、 SSL_read: Connection was aborted, errno 10053

1、情景再现

fatal: unable to access 'https://github.com/xxx.GitHub/xxxxxx.git/': OpenSSL SSL_read: Connection was aborted, errno 10053
  • 1

2、原因

可能是网络不稳定

3、解决办法

再试一次就好了,不行就同五的解决办法

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小丑西瓜9/article/detail/403383
推荐阅读
相关标签
  

闽ICP备14008679号