当前位置:   article > 正文

Git常见问题及解决(持续更新)_fix and commit

fix and commit

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下来但不覆盖当前修改部分

解决

  1. git stash
  2. git pull origin xx:xx
  3. git stash pop

参考git pull遇到错误:error: Your local changes to the following files would be overwritten by merge:_misaka去年夏天的博客-CSDN博客

3. 报错:no supported authentication methods available(server sent:publickey)

前提:tortoisegit,git clone ssh项目

解决

      (1) 生成ssh本地公钥

      (2) 在远端仓库添加公钥。

参考

        (1) tortoisegit常见错误Disconnected no supported authentication methods available(server sent: publickey)_git no supported authentication me_棉晗榜的博客-CSDN博客

        (2) Windows下生成SSH密钥 - 简书

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

参考IDEA git commit时出现can not commit changes due to unresolved conflicts_pending unresolved conflicts_keeper42的博客-CSDN博客

7. 在Android Studio中commit时出现line separator问题

前提:本地Win10,AS4.0.1进行commit时出现

原因:不同操作系统的换行符不同,

  1. LF -UNIX或macOS使用,换行符 \n
  2. CR -Classic macOS使用,换行符 \r
  3. CRLF -Windows使用,换行符 \r\n

解决:点Fix and Commit

参考

  1】 使用IDEA提交代码时提示You are about to commit CRLF line separators to the Git repository_EricXiao666的博客-CSDN博客

  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还原修改的文件

参考https://www.crifan.com/git_stash_pop_error_your_local_changes_to_the_following_files_would_be_overwritten_by_merge/

10. 用Git LFS上传大于25MB的文件

参考:

Github上传大文件(>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) 开全局代理

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/IT小白/article/detail/608515
推荐阅读
相关标签
  

闽ICP备14008679号