gitignore by file size?
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.
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.
Any suggestions?
I'm new to .gitignore, so there may be better ways to do this, but I've been excluding files by file size using:
find . -size +1G | cat >> .gitignore
Obviously you'll have to run this code frequently if you're generating a lot of large files.
Although the file size is very large and the following should not be an issue at all and provided that @abendine answer is correct, according to: https://stackoverflow.com/a/22057427/6466510
find * -size +1G | cat >> .gitignore
it would be far better. Have a look at this too: Difference between find . and find * in unix it turns out that replacing .
with *
here above, avoid to find things in .git
directory.
To satisfy github's <100MB file limit, run this:
find . -size +100M | cat >> .gitignore
I wanted to also offer a Windows version of this as well.
forfiles /s /c "cmd /q /c if @fsize GTR 1073741824 echo @relpath" >> .gitignore
(Update 2020-05)
Microsoft released time ago Git-LFS as Open-Source. Probably this is what most people really are searching for:
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."