Git | 使用遇到的 Bug及解决方法

Git | 使用遇到的Bug及解决方法

解决git clone速度慢的方法

这是我们要clone的

git clone https://github.com/Hackergeek/architecture-samples

使用镜像

git clone https://github.com.cnpmjs.org/Hackergeek/architecture-samples
//或者使用镜像
git clone https://git.sdut.me/Hackergeek/architecture-samples

几个可用的镜像源

https://hub.fastgit.org](https://hub.fastgit.org/)
https://github.com.cnpmjs.org](https://github.com.cnpmjs.org/)
https://github.bajins.com](https://github.bajins.com/)
https://github.rc1844.workers.dev](https://github.rc1844.workers.dev/)

合并代码遇到overwritten

error: Your local changes to the following files would be overwritten by merge

解决方法
  • 执行git stash 本地刚才修改的代码将会被暂时封存起来

  • git merge origin/feature-feed-user 重新合并

  • git stash pop 服务器上的代码更新到了本地,而且你本地修改的代码也没有被覆盖

  • 参考链接

提交代码遇到! [rejected]

To github.com:RobKing9/ByteGopher_SimpleDouyin.git ! [rejected] dev -> dev (non-fast-forward)

error: failed to push some refs to ‘github.com:RobKing9/ByteGopher_SimpleDouyin.git’

解决方法

说明远程仓库的代码比本地先更新 遇到了冲突 无法提交

  • 首先把远程仓库最新的代码拉下来 (参考上面 本地项目与Github同步的拉取代码)

  • 手动解决冲突 留下需要的代码 删除不需要的

    [外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-lTn9b4FA-1687065050303)(https://robking-123.oss-cn-beijing.aliyuncs.com/img/202305151525590.png)]

  • 再次执行 git add . -->git commit -m "" --> git push origin dev

提交代码遇到如下错误 key_exchange_identification

原因:ssh秘钥的过期,需要更新ssh的key

解决:把之前的pub文件删除,重新生成 参考链接

  • 执行ssh-keygen -t ed25519 -C "2768817839@qq.com"
  • 执行 ssh-agent bash 必须要执行
  • ssh-add ~/.ssh/id_ed25519
  • 将 SSH 公钥复制到剪贴板 clip < ~/.ssh/id_ed25519.pub 粘贴到github的ssh中
  • 所有操作完成后进行测试:
    ssh -T git@github.com

image-20230511011656316

后面频繁报错,可能是因为当时搞了一下git私服,导致config文件发生了错误,编辑 ~/.ssh/config 文件

改成

Host github.com
 Hostname ssh.github.com
 Port 443

image-20230513164343513

果然解决了

image-20230513164404821

参考

添加远程仓库遇到fatal: unsafe repository

fatal: unsafe repository (‘D:/AGolang/src/Aproject/ByteGopher_SimpleDouyin’ is owned by someone else)

解决方法

git 拒绝合并无关的历史

解决方法
  • 参考链接

  • 首先将远程仓库和本地仓库关联起来:
    
    git branch --set-upstream-to=origin/master master
    
    然后使用git pull整合远程仓库和本地仓库,
    
     --allow-unrelated-histories    (忽略版本不同造成的影响)
    

提交错误:fatal: sha1 file '<stdout>' write error

fatal: sha1 file '<stdout>' write error: Broken pipe
fatal: The remote end hung up unexpectedly

image-20230511011105832

原因:

  1. Git中的“智能HTTP”协议在POST请求中使用“Transfer-Encoding:chunked”,当它包含大小超过1MB的打包对象时。某些代理服务器(如Nginx)默认情况下不支持此传输编码,请求将在到达Bitbucket Server之前被拒绝。因此,Bitbucket Server日志不会显示任何额外信息。
  2. 可能的原因是负载均衡器配置错误,即是网速不好的时候。
  3. GitHub 提交文件的时候,当文件很大的时候,就会提醒;因为GitHub默认不允许提交超过100M的文件.

解决方案:

当推送大量数据时(初始推送大型存储库,使用非常大的文件进行更改)可能需要http.postBuffer 在git客户端 (而不是服务器)上设置更高的 设置 ;将Git缓冲区大小增加到repo的最大单个文件大小:

git config --global http.postBuffer 157286400
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值