Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

opposite of .gitignore file? [duplicate]

Tags:

git

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?

like image 341
morpheus Avatar asked May 15 '11 21:05

morpheus


People also ask

Can you have two Gitignore files?

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.

How do I ignore a Gitignore file?

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.

Should .gitignore be ignored?

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 .


2 Answers

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.

like image 53
sehe Avatar answered Sep 30 '22 09:09

sehe


You can use .gitignore for that.

*
!file0.txt
!file1.txt

In a case where you interested in file0.txt and file1.txt.

like image 31
tamasd Avatar answered Sep 30 '22 09:09

tamasd