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

终于稍微会一点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 README
git add README 
git commit -m 'first commit'
git push origin master
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值