I have the following .gitignore file:
bin/*
My project has the following structure:
myFolder
----bin
-------file
----anotherFolder
----yetAnotherFolder
The .gitignore is located in the folder myFolder
Why is file
still being committed?
I have the following .gitignore file:
bin/*
My project has the following structure:
myFolder
----bin
-------file
----anotherFolder
----yetAnotherFolder
The .gitignore is located in the folder myFolder
Why is file
still being committed?
There are several ways to use .gitignore
.
Literal File Names, ex:
.myFile
Directories, ex:
dir/
By adding the
/
in the end, the whole dir is ignored.
Wildcard, ex:
*.log
Negation, ex:
!example.log
Double Asteriks, ex:
**/logs
or logs/**/*.log
In your case, you should probably just use bin/
and it will ignore everything from inside that dir.
Just put the below in your .gitignore
instead of including the /*
bin
Will cause all files in that folder to be ignored.
If you have already committed the file then this won't work.
https://git-scm.com/docs/gitignore
A gitignore file specifies intentionally untracked files that Git should ignore. Files already tracked by Git are not affected; see the NOTES below for details.
If this is the case for you. Checkout this answer .gitignore after commit
If your file is updated during commits, it is because it is tracked.
The .gitignore has no effect on the process of making commits. The .gitignore file has the sole function of not adding files to be tracked. If you issue git add commands with wildcards, or for entire folders recursively, then your .gitignore will kick in and exclude those specified files.
If you wish to untrack a file, but still have it remain in your repo, then use
git rm --cached file
Be careful using git rm
, it deletes files for real!