Reputation: 81
If I have a folder called 'test' in my root, how do I put ignore so that the folder and all files/folders in it would be on gitignore? I've tried various tutorials, but nothing seems to be working. I bet its a very quick job?
Thanks!
Upvotes: 1
Views: 1352
Reputation: 476584
Simply use a wildcard: add
test/**
to the .gitignore
.
In Linux, a simple command to do this is:
echo 'test/**' >> .gitignore
in the root of the repository.
The **
unifies with all files in the directory and beyond.
This is sound with the .gitignore
documentation:
Two consecutive asterisks (
"**"
) in patterns matched against full pathname may have special meaning:
A leading
"**"
followed by a slash means match in all directories. For example,"**/foo"
matches file or directory"foo"
anywhere, the same as pattern"foo"
."**/foo/bar"
matches file or directory"bar"
anywhere that is directly under directory"foo"
.A trailing
"/**"
matches everything inside. For example,"abc/**"
matches all files inside directory"abc"
, relative to the location of the.gitignore
file, with infinite depth.A slash followed by two consecutive asterisks then a slash matches zero or more directories. For example,
"a/**/b"
matches"a/b"
,"a/x/b"
,"a/x/y/b"
and so on.Other consecutive asterisks are considered invalid.
(syntax modification, but same text).
Upvotes: 4
Reputation: 9403
You need .gitignore
in your projects directory. Add the following:
dir_to_ignore/**
More info here.
A trailing
/**
matches everything inside. For example,dir_to_ignore/**
matches all files inside directorydir_to_ignore
, relative to the location of the .gitignore file, with infinite depth.
Upvotes: 1