git错误总结

字数 308阅读 1536

错误一

Updates were rejected because the remote contains work that you do

 ! [rejected]        master -> master (fetch first)
error: failed to push some refs to 'https://github.com/icessun/baiduWebShool.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 pull origin master     抓取远端的内容
$ git push origin master     重新推送到远程仓库

错误二

Your local changes to the following files would be overwritten by checkout:

Administrator MINGW32 /d/blog (dev)
$ git checkout master
error: Your local changes to the following files would be overwritten by checkout:
        .idea/workspace.xml
Please commit your changes or stash them before you switch branches.
Aborting


错误的原因是:直接在远程仓库包操作了,修改了github上面的东西,相当于服务器上面的东西,而本地没有修改,当想改变分支的时候,出现了改变分支的时候会重写文件,所以必须把修改的提交到版本库里面。或者是隐藏在你切换分支之前。


解决办法:

  • 抛弃本地的修改,回到上一个版本
git reset --hard
然后,切换你的分支
git checkout master 

错误三

src refspec remote does not match any

$ git push origin remote
error: src refspec remote does not match any.
error: failed to push some refs to 'git@github.com:icessun/ife-fcc.git'

查看了stackoverflow上面的解答,发现是目录中没有文件,空目录是不能提交上去的


解决办法:

$ git push -u origin remote

错误四

错误四

解决办法:

git config http.postBuffer 524288000

错误五

git pull 失败 ,提示:fatal: refusing to merge unrelated histories


错误五

解决办法:
git pull origin master --allow-unrelated-histories

推荐阅读更多精彩内容