在常规Git下移动Git LFS跟踪的文件 [英] Move Git LFS tracked files under regular Git

查看:160
本文介绍了在常规Git下移动Git LFS跟踪的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个项目,其中使用Git LFS存储了视频文件.现在,我的构建服务器还不支持Git LFS,因此遇到了一些麻烦.由于它是一项外部服务,因此我无法真正影响构建过程,因此希望将文件从Git LFS下移回常规" Git.我设法用git lfs untrack '<file-type>'取消跟踪文件类型,但是git lfs ls-files仍然给出了以前添加的文件的列表.

I have a project where I stored video files with Git LFS. Now I ran into some complications with my build server that doesn't yet support Git LFS. As it's an external service, I can't really affect the build process, and thus would want to move the files from under Git LFS back to "regular" Git. I managed to untrack the file types with git lfs untrack '<file-type>' but git lfs ls-files still gives a list of the files previously added.

我想我可以删除文件,推送更改,然后手动重新添加它们,但这真的是推荐的处理方式吗?

I imagine I could remove the files, push the changes and then manually re-add them, but is this really the recommended way of doing things?

推荐答案

我最近遇到了这个问题,在这个问题上,资产被意外地添加到了本不应该添加到一个分支上的git-lfs中.我的解决方案是:

I have just recently run into this problem where assets were accidentally added to git-lfs on one branch that shouldn't have been. My solution was:

git lfs untrack '<file-type>'
git rm --cached '<file-type>'
git add '<file-type>'
git commit -m "restore '<file-type>' to git from lfs"

结果是使用标准文件内容重写了git-lfs oid sha256指针.

The result is a rewrite of the git-lfs oid sha256 pointers with the standard file contents.

(编辑2019-03):更改了可接受的答案,以为更简单的情况提供简单的解决方案.另请参阅 VonC答案中的编辑内容,以备其他解决方案,以防万一您手头更为复杂.

(Edit 2019-03): The accepted answer was changed to provide an easy solution for simpler cases. See also the edits in the answer by VonC for alternate solutions in case you have a more complex case on hand.

这篇关于在常规Git下移动Git LFS跟踪的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆