1. Git remote: invalid username or password Solution
前提:git push,登陆账密正确,有2FA
解决:有2FA需要用personal access token作为密码
参考:Git remote: invalid username or password Solution | Career Karma
2. error: Your local changes to the following files would be overwritten by merge
前提:git pull,在local修改文件后想从remote把最新的repo pull下来但不覆盖当前修改部分
解决:
git stash
git pull origin xx:xx
git stash pop
3. 报错:no supported authentication methods available(server sent:publickey)
前提:tortoisegit,git clone ssh项目
解决:
(1) 生成ssh本地公钥;
(2) 在远端仓库添加公钥。
参考:
4. error: Pulling is not possible because you have unmerged files
解决:
按以下3步
(1) git add .
(2) git commit -m "xx"
(3) git pull origin xx:xx
参考:error: Pulling is not possible because you have unmerged files_mango_love的博客-CSDN博客
git pull报错Pulling is not possible because you have unmerged files_帅阿星的博客-CSDN博客
原因:Todo
5. error: src refspec main does not match any.
前提:新建github仓库,参考官网命令,在将本地仓库用push -u origin main到远程时报错
原因:本地初始仓库分支名是master,而从2020.10.1起,github创建仓库的默认分支为main,所以命令里是push本地main到远程,而本地main为空仓库。
解决:用“git branch -M main”重命名当前分支为main
参考:
(1) https://www.cnblogs.com/jeremylee/p/5715289.html
(2) 如何看待github将master分支改名为main? - 知乎
(3) Git - git-branch Documentation
6. can not commit changes due to unresolved conflicts
前提:用as进行commit时显示如上错误
解决:重新git add . -》 as进行commit-》push
7. 在Android Studio中commit时出现line separator问题
前提:本地Win10,AS4.0.1进行commit时出现
原因:不同操作系统的换行符不同,
LF -UNIX或macOS使用,换行符 \n
CR -Classic macOS使用,换行符 \r
CRLF -Windows使用,换行符 \r\n
解决:点Fix and Commit
参考:
2】 Configuring Git to handle line endings - GitHub Docs
3】 Git core.autocrlf 配置说明 - 陈斌彬的技术博客
8. 用git clone时报错“fatal: unable to access 'url': Failed to connect to github.com port 443: Timed out”
解决:
(1) 把url换成https或ssh()的标准url
9. 在git stash-》git pull-》git unstash后报错
原因:在git stash后又去修改了一些文件导致
解决: 点View them还原修改的文件
10. 用Git LFS上传大于25MB的文件
参考:
轻松上传超过100M的文件至GitHub - 腾讯云开发者社区-腾讯云
11. fatal: unable to access 'https://github.com/eHackyd/库名': Failed to connect to github.com port 443 after 21069 ms: Couldn't connect to server
参考:解决 Failed to connect to github.com port 443:connection timed out_fK0pS的博客-CSDN博客
(1) 重启命令行
(2) 关闭代理
(3) 开全局代理