windows使用git时会出现的常见操作问题解答

来源:互联网 发布:virtualbox mac 10.13 编辑:程序博客网 时间:2024/05/29 16:26

终于稍微会一点git了,所以赶紧把遇到的问题记录下来:
1、warning: LF will be replaced by CRLF
windows中的换行符为 CRLF, 而在Linux下的换行符为LF,所以在执行add . 时出现提示,解决办法:

$ rm -rf .git          // 删除.git  $ git config --global core.autocrlf false      //禁用自动转换 

然后重新执行:

$ git init    $ git add .  

2、fatal: remote origin already exists
输入$ git remote add origin 项目地址时出现出错信息;
解决办法:

$ git remote rm origin$ git remote add origin 

然后再输入项目地址 就不会报错了。
3、error:failed to push som refs to …….
输入$ git push origin master时出现出错信息;
解决方法:

$ git pull origin master   //先把远程服务器github上面的文件拉下来$ git push origin master

4、 fatal: Couldn’t find remote ref master或者fatal: ‘origin’ does not appear to be a git repository以及fatal: Could not read from remote repository.
重新输入

$ git remote add origin 项目地址

5、error:src refspec master does not match any
引起该错误的原因是,目录中没有文件,空目录是不能提交上去的;

touch READMEgit add README git commit -m 'first commit'git push origin master
0 0
原创粉丝点击