zhengmingmingf

Git使用过程几个问题解决

1 Git提交时(执行git add .)提示‘The file will have its original line endings in your working directory’

warning: LF will be replaced by CRLF

warning: LF will be replaced by CRLF in xxxxx

The file will have its original line endings in your working directory.

原来是Git默认配置替换回车换行成统一的CRLF,我们只需要修改配置禁用该功能即可。

Gitshell中输入如下命令解决:

git config --global core.autocrlf false

2 执行git push -u origin master,报错 failed to push some refs to xxxx

git push origin master 向远程仓库推送的时候报如下错误:

error: failed to push some refs to 'https://github.com/ZJyoung1997/JZShop.git'
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.

原因是远程仓库中的文件和我们本地的仓库有差异,例如你的远程仓库有个文件Readme. md,但是本地仓库却没有,就可能会出现这种情况。

解决办法:
git pull --rebase origin master
我使用过程中还是报错,那么需要清除缓存,再次进行此命令,问题解决(可以重新再次上传,再次上传之前,先清除本地的git文件(那个隐藏文件夹))

posted on 2019-10-18 16:47  zhengmingmingf  阅读(187)  评论(0)    收藏  举报

导航