I try to ignore file in a directory by relative path. E.g. I have several directories in working tree lib/file.f
and I want all occurrences of this file to be ignored. I tried
lib/file.f
but this does not work.
I try to ignore file in a directory by relative path. E.g. I have several directories in working tree lib/file.f
and I want all occurrences of this file to be ignored. I tried
lib/file.f
but this does not work.
Place
*/lib/file.f
in your .gitignore
. This will cause git to ignore any file of the form project/<DIR>/lib/file.f
, assuming .gitignore
is in the project
directory.
To make git ignore lib/file.f
two directories down, you'd also have to add
*/*/lib/file.f
to the .gitignore
, and so on.
Vastly simpler of course, would be to place
*file.f
in .gitignore
to block all files named file.f
, but your question seems to suggest there is at least one file by that name you wish not to ignore.
also you might want to remove the file from git cache, in order to check what you just ignored:
git rm --cached lib/file.f
this is if you already added the file to git index
If you want to specify all sub-folders under specific folder use /**/
. To ignore all file.f
files in a /src/main/
folder and sub-folders use:
/src/main/**/file.f