咚咚枪干翻你 發表於 2020-2-18 12:33:00

一次从Github向Gitee迁库踩坑记录

<p>先上结论:<strong>gitee的lfs功能收费,直接从github迁移包含lfs管理的文件会出错,配置lfs.url即可解决问题</strong></p>
<blockquote>
<p>Q: 为什么要迁库呢?<br>
A: github访问太慢了,不然我也不想费这个功夫!</p>
</blockquote>
<p>gitee自带的有从github同步仓库的功能,一般来说该功能非常方便。<br>
然而,我们的<strong>github库使用了lfs</strong>,这就是踩坑的开始。</p>
<p>1.跟往常一样,直接在gitee中一键导入github仓库,一切正常。我还专门新建了一个文本文件测试了一下,上传成功,以为万事大吉了。<br>
2.过了几个小时,一位成员突然给我说clone库的时候出错了,我一脸懵逼,Error downloading object Smudge error: Error downloading这是啥错?我没问题啊!<br>
<img src="https://img2018.cnblogs.com/blog/1899871/202002/1899871-20200218115502926-1883795142.png" alt="" loading="lazy"><br>
3.我自己clone了一下,发现报了一样的错误。在网上搜了半天发现貌似是二进制文件下载出了问题,在stackoverflow中找到了答案(在这吐槽一下,百度半小时,谷歌一分钟)</p>
<blockquote>
<p>In my case the SSH-authenticated repository was updated to use LFS from another client and on my side Git-LFS didn't know about the SSH remote-url.<br>
What I did to fix it was the following:<br>
Copy the URL configured in remote.origin.url (push URL for origin) to lfs.url (the URL LFS uses):<br>
<code>$ git config lfs.url $(git config remote.origin.url)</code><br>
(If your remote is not named origin then change to your remote name.)<br>
Then run<br>
<code>$ git config lfs.url</code><br>
to show the URL and confirm that it does indeed contain an SSH url, and not some HTTP/HTTPS url.<br>
Then you can<br>
<code>$ git pull</code><br>
Done.<br>
See also: https://github.com/git-lfs/git-lfs/issues/2661#issuecomment-335903332</p>
</blockquote>
<p>简单来说就是<strong>git找不到lfs文件的位置</strong>,我去gitee上一看,果然那些大文件都是not found,然后配置一下lfs.url即可<br>
<img src="https://img2018.cnblogs.com/blog/1899871/202002/1899871-20200218120343431-2046024402.png" alt="" loading="lazy"><br>
<code> git config lfs.url https://github.com/xxxxx.git</code><br>
4.配置完成后,我重新clone了一下,很好,没有报错,二进制文件也下载了。<br>
5.然而我想上传一个大文件时,报了一个更离谱的错误ERROR: Authentication error: Authentication required: Authorization error:<br>
没有权限?我是仓库管理员啊!<br>
<img src="https://img2018.cnblogs.com/blog/1899871/202002/1899871-20200218122214694-1422278629.png" alt="" loading="lazy"><br>
查询后发现,这不是git权限报错,而是git lfs没有权限,我这才想起来去看看gitee支不支持lfs,结果如下:<br>
<img src="https://img2018.cnblogs.com/blog/1899871/202002/1899871-20200218122715787-1501700899.png" alt="" loading="lazy"><br>
至此,破案了,lfs功能收费,我先发个邮件去问问,后续再更......</p>
<p>不对,该问题是由git lfs功能引起的,在github中也有不少人遇到</p>
<pre><code>$ rm .git/hooks/pre-push
$ git push
</code></pre>
<p>可以解决没有授权的问题<br>
感觉目前是这样:lfs是另外的库由github保管,其他没有被lfs track的文件可以上传到gitee,配置lfs.url后大文件还是放在github<br>
不需要gitee的付费功能/hh</p><br><br>
来源:https://www.cnblogs.com/unnling/p/12325689.html
頁: [1]
查看完整版本: 一次从Github向Gitee迁库踩坑记录