gitignore by file size?

前端 未结 5 641
难免孤独
难免孤独 2020-12-04 10:14

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

相关标签:
5条回答
  • 2020-12-04 10:50

    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.

    0 讨论(0)
  • 2020-12-04 10:54

    To satisfy github's <100MB file limit, run this:

    find . -size +100M | cat >> .gitignore
    
    0 讨论(0)
  • 2020-12-04 10:59

    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
    
    0 讨论(0)
  • 2020-12-04 11:03

    (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."

    0 讨论(0)
  • 2020-12-04 11:11

    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.

    0 讨论(0)
提交回复
热议问题