git 移除 LFS
2021-06-23 本文已影响0人
Angeladaddy
公司内网搭建的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执行(略)
- 另一种方法针对 git verison> 2.16,可使用(未测试):
git lfs untrack '<pattern>'
git add --renormalize .
git commit -m 'Restore file contents that were previously in LFS'
<pattern>
可以换成*