Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to ignore all dist folders except the one?

Tags:

git

gitignore

we do have a few folders in our projects called dist. These shall be ignored by git. On the other hands just putting dist/ into the .gitignore file does have side effects when using bower, since the dist folders within bower_components/ are ignored as well.

Any suggestions on how to correctly define a rule, that ignore dist folders except the ones within bower_components?

like image 584
Moritz Herbert Avatar asked May 02 '16 13:05

Moritz Herbert


People also ask

How do I Gitignore everything except?

You want to use /* instead of * or */ in most cases The above code would ignore all files except for . gitignore , README.md , folder/a/file. txt , folder/a/b1/ and folder/a/b2/ and everything contained in those last two folders.

Can Gitignore ignore folders?

gitignore is a plain text file in which each line contains a pattern for files or directories to ignore. It uses globbing patterns to match filenames with wildcard characters. If you have files or directories containing a wildcard pattern, you can use a single backslash ( \ ) to escape the character.

Can you have more than one Gitignore?

You can have multiple . gitignore , each one of course in its own directory. To check which gitignore rule is responsible for ignoring a file, use git check-ignore : git check-ignore -v -- afile .


1 Answers

Sure:

dist/
!bower_components/**/dist/
like image 115
Vampire Avatar answered Oct 17 '22 11:10

Vampire