0

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?

CelineDion
  • 906
  • 5
  • 21
  • Is .gitignore placed in the root of the project? Have you tried removing the leading './' from each entry? Refer to the documentation https://git-scm.com/docs/gitignore for the correct syntax. – aksamit Oct 11 '18 at 21:59

2 Answers2

1

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.

CelineDion
  • 906
  • 5
  • 21
  • 1
    It's not so much "preceded by a dot" as the fact that the file's name is `data/9-26/18/altrans/Thyroid.Altrans.bestPerLink`, for instance. The name is not `./data/9-26-18/altrans/Thyroid.Altrans.bestPerLink`. Except for the special case of slashless names or `*` or `**` matches, Git is not doing component-analysis of the names: the name is just a string. – torek Oct 11 '18 at 20:41
1

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-

(the cut -c3- discards the leading ./ that this find prints).

You can run these names through git check-ignore to see if they are already ignored, and if not, add them to .gitignore:

[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 .gitignore file itself will not grow so large as to cause problems. If it would, be sure to eliminate .gitignore as an ignored file even if .gitignore exceeds your size threshold, e.g.:

find . -name .git -prune -o -name .gitignore -prune -o -size +$limit -print

where $limit is the size threshold (100M for 100 megabytes, 10k for 10 kbytes, etc).

torek
  • 448,244
  • 59
  • 642
  • 775
  • Thanks. I actually figured out the problem I had specifically and the code I ended up using was `find ./* -size +100M | cut -c 2-| cat >> .gitignore` but this is definitely informative. – CelineDion Oct 12 '18 at 20:26