Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can .gitignore files be named ? (e.g. xxx.gitignore)

I would like to know whether it is possible to have named .gitignore files in a repository, such as:

Composer.gitignore
Node.gitignore

Both of the above examples are shown available in GitHub's gitignore template repository (perhaps this might be a bit misleading).

I have tried adding Composer.gitignore to my repository and it seems like the file is not read (I'm using SourceTree).

EDIT:

Adding relevant information added by Boldewyn that does not directly answer the question:

The page's README says:

A Collection of .gitignore templates and that's what it is: Only templates. If you want to use one, pick it, drop it in your repository and rename it to .gitignore.

git recognizes only two places for listing ignored files: .gitignore files in a folder/subfolder and the file .git/info/ignore. See git help gitignore for in-depth information.

like image 801
jolian Avatar asked Dec 25 '22 21:12

jolian


1 Answers

The only way you could make a file not name .gitignore as a .gitignore file is:

  • reference it directly

    git config --global core.excludesfile ~/myfile.gitignore
    
  • generate it through a smudge script from a content filter driver.
    That second option is a bit convoluted, but would process all versionned <file>.gitignore and generate the final .gitignore.

Other than those two options, the .gitignore man page doesn't allow any other naming convention.

like image 145
VonC Avatar answered Jan 05 '23 17:01

VonC