Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does !*/ mean in .gitignore

Tags:

git

gitignore

With git version 1.7.1, I'm trying to exclude all files except .php files.

The working solution I found relies on the command !*/

# Ignore Everything *  # Except these files !.gitignore !*/ !*.php 

Without the !*/, it will only include the *.php files in the root directory. What is !*/ doing that allows this to work?

like image 578
bitsoflogic Avatar asked Aug 28 '14 17:08

bitsoflogic


People also ask

What does exclamation mean in Gitignore?

logs/important.log. Prepending an exclamation mark to a pattern negates it. If a file matches a pattern, but also matches a negating pattern defined later in the file, it will not be ignored.

What means in Git ignore?

gitignore file is a text file that tells Git which files or folders to ignore in a project. A local . gitignore file is usually placed in the root directory of a project. You can also create a global . gitignore file and any entries in that file will be ignored in all of your Git repositories.

What should I write in Gitignore?

gitignore should list the names or name-patterns of files that will be found in work-trees when working with your project, but that should not be committed to the project. In other words, it's not OS-specific, it's project-specific.


1 Answers

Take a look at the documentation of gitignore

An optional prefix "!" which negates the pattern; any matching file excluded by a previous pattern will become included again. It is not possible to re-include a file if a parent directory of that file is excluded. Git doesn’t list excluded directories for performance reasons, so any patterns on contained files have no effect, no matter where they are defined. Put a backslash ("\") in front of the first "!" for patterns that begin with a literal "!", for example, "!important!.txt".

like image 168
Bijan Avatar answered Oct 11 '22 13:10

Bijan