git gitignore 按文件大小?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4035779/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
gitignore by file size?
提问by Warren Benedetto
I'm trying to implement Git to manage creative assets (Photoshop, Illustrator, Maya, etc.), and I'd like to exclude files from Git based on file size rather than extension, location, etc.
我正在尝试实施 Git 来管理创意资产(Photoshop、Illustrator、Maya 等),我想根据文件大小而不是扩展名、位置等从 Git 中排除文件。
For example, I don't want to exclude all .avi files, but there are a handful of massive +1GB avi files in random directories that I don't want to commit.
例如,我不想排除所有 .avi 文件,但在我不想提交的随机目录中存在少量大量 +1GB avi 文件。
Any suggestions?
有什么建议?
回答by abendine
I'm new to .gitignore, so there may be better ways to do this, but I've been excluding files by file size using:
我是 .gitignore 的新手,所以可能有更好的方法来做到这一点,但我一直在使用以下方法按文件大小排除文件:
find . -size +1G | cat >> .gitignore
Obviously you'll have to run this code frequently if you're generating a lot of large files.
显然,如果要生成大量大文件,则必须经常运行此代码。
回答by tisaconundrum
I wanted to also offer a Windows version of this as well.
我也想提供一个 Windows 版本。
forfiles /s /c "cmd /q /c if @fsize GTR 1073741824 echo @relpath" >> .gitignore
回答by earizon
(Update 2020-05)
(更新 2020-05)
Microsoft released time ago Git-LFS as Open-Source. Probably this is what most people really are searching for:
微软不久前将 Git-LFS 作为开源发布。可能这就是大多数人真正正在寻找的:
https://git-lfs.github.com/C&P from the project page: "Git Large File Storage (LFS) replaces large files such as audio samples, videos, datasets, and graphics with text pointers inside Git, while storing the file contents on a remote server like GitHub.com or GitHub Enterprise."
https://git-lfs.github.com/来自项目页面的 C&P:“Git 大文件存储 (LFS) 将音频样本、视频、数据集和图形等大文件替换为 Git 内部的文本指针,同时存储文件GitHub.com 或 GitHub Enterprise 等远程服务器上的内容。”