I have following folders in my project.
public/first/A
public/second/A
public/first/B
public/second/B
And similarly I've other folders which is also in public/first
and public/second
.
To ignore these folders I need to add following to .gitignore :
/public/first/A
/public/second/A
....
Is there a way which I can follow to mention A
and B
folder only once in gitignore and they will be ignored from both /public/first
and /public/second
.
Note: Folders with A & B name with different content might be available in other folders like
public/first/app/A
and it should not be ignored.
Assuming that there is no /public/third/A
scenario, you can use a wildcard to specify the first
and second
part. Like this
/public/*/A/
/public/*/B/
Also, you need to put a /
after a folder in gitignore. If you don't, git treats it like a file declaration instead of a folder.