Possible Duplicate:
Make .gitignore ignore everything except a few files
Is it possible to let git ignore all files by default, unless specified in a special file?
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 . gitignore files.
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.
The . gitignore file's purpose is to prevent everyone who collaborates on a project from accidentally commiting some common files in a project, such as generated cache files. Therefore you should not ignore .
You can include !-lines to whitelist files: a .gitignore with:
* !included/
will exclude all, but the 'included/' directory
Note that if you want files matching a pattern to be un-ignored, in subdirectories, you will need to prevent the containing directories from getting ignored too. This should not pose a large problem, since git doesn't actually track directories, only files (identified by a repository path).
Example:
* !*/ !SOURCES
will ignore everything, except SOURCES
in subdirectories.
You can use .gitignore for that.
*
!file0.txt
!file1.txt
In a case where you interested in file0.txt and file1.txt.
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