git使用中常见报错解决方法

1、hint: You've added another git repository inside your current repository.

      大概意思:在当前的仓库中还包含有另一个.git仓库而且不知道这两个仓库的嵌套关系。

      解决方法:git rm --caches phto

2、 ! [rejected]        master -> master (fetch first)

      大概意思:因为github上的远程库与本地库版本不一致

      解决方法:

      一、先拉一遍再上传

             1、更新 git fetch origin master

             2、比较本地的仓库和远程参考的区别
                  $ git log -p master.. origin/master
             3、把远程下载下来的代码合并到本地仓库,远程的和本地的合并
                  $ git merge origin/master

      二、暴力覆盖,直接将远程仓库里的文件覆盖掉

                  $ git push -f origin master

3、fatal: remote origin already exists.

      解决方法:

      1、先移除  git remote rm origin   

      2、再添加  git remote add origin https://github.com/......

4、[git]warning: LF will be replaced by CRLF in

      大概意思:需要提交的文件是在windows下生成的,windows中的换行符为 CRLF, 而在linux下的换行符为LF,所以在执行add . 时出现提示

      解决方法:

      1、git config --global core.autocrlf false   

      2、再执行一遍git 提交

原文地址:https://www.cnblogs.com/MrTager/p/12896212.html