I need to ignore all files except those ending in .php
, .css
, .html
or .js
.
This is what I have in my .gitignore file for now:
* !.php !/*.php !*.php
It does ignore everything, but only permits .php
files in root directory, while hiding all the rest.
Open the . git/info/exclude file in a text editor and add the folder to ignore. This file remains private to you.
A . gitignore file is a plain text file where each line contains a pattern for files/directories to ignore. Generally, this is placed in the root folder of the repository, and that's what I recommend. However, you can put it in any folder in the repository and you can also have multiple .
A file with the GITIGNORE file extension is a Git Ignore file used with the version/source control system called Git.
* !*/ !*.php !*.css !*.html !*.js
For those, who would like to include file extensions which are located in subdirs like @jmborr and @Racso
# .gitignore for excluding all but certain files in certain subdirs * !*.cfg !/**/ !certain/subdir/i_want_to_include/*.cfg
when you exclude everything ('*'), you have to white-list folders ('/**/'), before being able to white-list files.
Found in: https://stackoverflow.com/a/33983585/5388625
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With