mostlyhuman
mostlyhuman

Reputation: 51

How to exclude all subfolders with a specific name in .gitignore

I have several subfolders in various parts of my project called "autosave" and I want .gitignore to ignore any subfolder called "autosave" regardless of where it is in the project, how would I do this?

I am kinda new with git but I did try */autosave/ but that doesn't appear to work. Also, some are capitalized and some aren't (Autosave and autosave).

Upvotes: 1

Views: 821

Answers (1)

VonC
VonC

Reputation: 1324278

A simple line should be enough

autosave/
Autosave/

That will ignore any autosave folder (anywhere).
It should be the equivalent of **/autosave/

See gitignore pattern format:

If the pattern ends with a slash, it is removed for the purpose of the following description, but it would only find a match with a directory.

In other words, foo/ will match a directory foo and paths underneath it, but will not match a regular file or a symbolic link foo (this is consistent with the way how pathspec works in general in Git).

Upvotes: 1

Related Questions