git is not recognizing entries in my gitignore file
I followed directions found here and I am still ending up with the same handful of files. Even if I specifically invoke
git -rm --cached those/files*, when I call
git status I still see those same files in under "Untracked files:"
Here is what my gitignore file looks like:
# Files that exceed 100MB # ########################### ./data/9-26-18/altrans/SkinSunExposedLowerleg.Altrans.bestPerLink ./data/9-26-18/altrans/MuscleSkeletal.Altrans.bestPerLink ./data/9-26-18/altrans/Thyroid.Altrans.bestPerLink ./data/9-26-18/altrans/WholeBlood.Altrans.bestPerLink ./data/9-26-18/altrans/NerveTibial.Altrans.bestPerLink ./data/9-26-18/altrans/HeartLeftVentricle.Altrans.bestPerLink ./data/9-26-18/altrans/Lung.Altrans.bestPerLink ./data/9-26-18/altrans/AdiposeSubcutaneous.Altrans.bestPerLink ./data/9-26-18/altrans/ArteryTibial.Altrans.bestPerLink
How do I make it so that these files, along with any other files I enter into .gitignore which exceeds 100MB in the future, are not even untracked, but are ignored altogether?
Damn, I think I just realized the problem: for some reason, gitignore will not pick up on files preceded with a dot. So I have to remove these dots for gitignore to work, apparently. If someone could tell me why that is, it would be greatly appreciated.
There is no built in "ignore by size". You could write a program that inspects files, and for those that exceed some size threshold, updates the
.gitignore. A very simple shell script version to find "large files" is:
find . -name .git -prune -o -size +100M -print | cut -c3-
cut -c3-discards the leading
You can run these names through
git check-ignoreto see if they are already ignored, and if not, add them to
[find expression as above] | while read -r name; do git check-ignore -q "$name" || printf '%s\n' $name >> .gitignore done
Note that this assumes the
.gitignorefile itself will not grow so large as to cause problems. If it would, be sure to eliminate
.gitignoreas an ignored file even if
.gitignoreexceeds your size threshold, e.g.:
find . -name .git -prune -o -name .gitignore -prune -o -size +$limit -print
$limitis the size threshold (100M for 100 megabytes, 10k for 10 kbytes, etc).