likes
comments
collection
share

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

作者站长头像
站长
· 阅读数 12

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 | 使用遇到的`Bug`及解决方法

解决方法

  • 执行git stash 本地刚才修改的代码将会被暂时封存起来
  • git merge origin/feature-feed-user 重新合并

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

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

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

  • 参考链接

提交代码遇到! [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'

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

解决方法

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

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

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

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

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

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

提交代码遇到如下错误 key_exchange_identification

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

原因: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

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

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

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

改成

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

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

果然解决了

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

参考

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

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

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

解决方法

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

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

原因:

  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