I've been frustrating when I cannot successfully make git ignore huge files such as 'node_modules' or 'mysql' etc.
Today I totally figured out why sometimes it doesn't work as I wish.
The biggest reason is that I have no idea if I want to ignore certain file, I DO NOT need to write the relative path to it, JUST have to write the name of the file or the folder, without any slash.
As long as you don't have one file with the same name in the same project folder and futhermore you don't want to ignore that one.
The reason why is because only writing the name of the file or the folder would make git ignore all the files with that name.
#1 work #2 /work #3 work/ #4 /work/
every work folder would be ignored
the work folder which is on the same directory with .gitignore would be ignored
same with #1
same with #2
I recommend only having one .gitignore and put it on the root directory.
(you can have two, and if so the one on the deeper layer would be executed first)
Personally I feel it's confusing.
One last thing,
once you added/committed something, you have to delete its cache so you can let git ignore it.
The command following.
$ git rm --cached <file or directory>
Thank you for reading, happy coding:)