git出现错误一览

版权声明:老哥,这些都是我手打的,给点面子 https://blog.csdn.net/weixin_43312108/article/details/87704585

在使用了 git push origin master

首先出现的错误代码如下

fatal: 'origin' does not appear to be a git repository
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

这个代码错误原因有很多,其中作为 解决方法之一

git push origin master@github:vcbal2580/myProject

而后又出现了

error: src refspec master@github does not match any.
error: failed to push some refs to 'origin'

这个原因在于作为仓库文件 中是空文件,空目录无法上传,额,虽然我出错的主要原因不在于这个,我的原因应该在于远程库与本地库不一致,将其同步即可

git pull --rebase origin master

​ 这条指令的意思是把远程库中的更新合并到本地库中,–rebase的作用是取消掉本地库中刚刚的commit,并把他们接到更新后的版本库之中。用于解决冲突问题。

解决方法在于 加个文件 啊

touch README
git add README 
git commit -m 'first commit'
git push origin master

然后之后 我又出现错误

$ git commit -m "阿达abc"
On branch master
nothing to commit, working tree clean

这个东西是错的根本问题 ,原因在于有文件名没有对上,譬如大小写问题,因为git配置里面默认忽略大小写,故添加代码


在上线项目的时候 出现了

master warning: LF will be replaced by CRLF in www/css/style.css.>

原因在于原来 CRLF和LF是两种不同的换行格式,git工作区默认为CRLF来作为换行符,windows中的换行符为 CRLF,而在Linux下的换行符为LF,所以在执行add . 时出现提示

解决方式:
我们可以在git命令行中输入如下指令:

rm -rf .git // 删除.git
git config –global core.autocrlf false //禁用自动转换
git init //初始化git库

git add –all //提交所有修改到暂存区

嗯。。。。。然后呢 我切换了一下,又tm 出现了

fatal: unable to access 'https://github.com/lesterhnu/tp5.git/': Empty reply from server

这个错误,但是呢,过了几分钟重新上传了,看了看网上的解说无非是网络通道被抢了

比如现在你的repo地址是:
https: //github.com/xxx/xxx.github.io.git 
那就把https://换成git@,如下:
[email protected]:xxx/xxx.github.io.git

关于git中出现

$ git push -u gitee master
To https://github.com/vcbal2580/-.git
! [rejected] master -> master (fetch first)
error: failed to push some refs to 'https://github.com/vcbal2580/-.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.

原因在于git冲突,远程库与本地库中的文件不符,解决方法根据思路划分有两种
一、以本地为主,强行覆盖远程库
命令
$ git push origin master -f
二、下载远程库,并使其与本地库合并
使用语法
git pull [options][</reposit/>][…]
如果想要远程分支的东西则需要
$ git pull origin master --allow-unrelated-histories

猜你喜欢

转载自blog.csdn.net/weixin_43312108/article/details/87704585