Today I learned that I can set up my own filters for doing substitutions on commit/checkout with Git.
Why is that useful?
GitHub restricts files to 100 MB. What if you want to push a file to your GitHub repository that’s bigger than 100 MB?
You can use Clean and Smudge to compress your file.
images are from https://git-scm.com/book/en/v2/Customizing-Git-Git-Attributes
Clean and Smudge⌗
- Decide which file types you want to compress and add them to
For example, for
.csv files, add the following line to a file
.gitattributes in your Git repository.
compress is the name of the filter you have to set up. But you can name it however you like.
- Write your compress filter
In the terminal inside the root folder of your Git project, add the following commands:
git config filter.compress.clean gzip git config filter.compress.smudge gzip -d
The name of the git filter is
compress. It uses gzip to compress the files on
clean (before files are staged), and de-compress them on
smudge (before files are checked out).