Search code examples
gitgitignore

Avoiding .gitignore on one folder


I have a .gitignore file on my repository to prevent uploading some files.

But I want to have a single folder inside this repository where all kind of files are allowed.

How can I scape the gitignore on that folder?


Solution

  • You can negate patterns in .gitignore, causing otherwise excluded files to be included.

    !folderX/**/*
    

    A line like this in .gitignore will "unexclude" all files in folderX and its subfolders.

    Note: The .gitignore file is parsed from top to bottom. Add this line at the end.
    Any rule that comes after this line can override its effect.