git 移除 LFS

公司内网搭建的gitlab,做了端口映射可以在家里访问,但是git lfs pull的时候走不动,检查原因是lfs使用的依然是gitlab里设置的内网地址。所以决定移除工程的lfs支持:
代码转自 Simple steps to uninstall Git LFS from your repository · Issue #3026 · git-lfs/git-lfs (github.com)

#commit & push everything
#remove hooks
git lfs uninstall
#remove lfs stuff from .gitattributes
#list lfs files using
git lfs ls-files | sed -r 's/^.{13}//' > files.txt
#run git rm --cached for each file
while read line; do git rm --cached "$line"; done < files.txt
#run git add for each file
while read line; do git add "$line"; done < files.txt
#commit everything
git add .gitattributes
git commit -m "unlfs"
git push origin
#check that no lfs files left
git lfs ls-files
#remove junk
rm -rf .git/lfs
#you're all done
#(but unlinked junk is within BitBucket Git LFS storage still)

windows以上命令如果运行不成功,可以自行安装wsl执行(略)

  1. 另一种方法针对 git verison> 2.16,可使用(未测试):
git lfs untrack '<pattern>'
git add --renormalize .
git commit -m 'Restore file contents that were previously in LFS'

<pattern> 可以换成*

最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容