记录Git报错

First Post:

Last Update:

一、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添加文件到暂存区时警告

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

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 提交代码到远程仓库时报错

1
2
3
4
5
6
7
 ! [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.

2、原因:

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

3、解决办法:

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

1
git pull --rebase origin main
打赏
支付宝 | Alipay
微信 | WeChat