Search code examples
gitignore

.gitignore - Ignore everything in a directory except one file


I know there is a lot of questions like this, but no one solved my problem. I want something very simple - ignore all files and folders under specific folder except one file. This is what I try:

#Ignore
public/typings/*

#Allow
!public/typings/browser/ambient/jquery/jquery.d.ts

...but the file is still ignored.

Any suggestions?


Solution

  • If the file was added in a previous commit before you put it in git ignore, it's possible your .gitignore is not working. I had the same problem few days ago. I solved the problem thanks to this post:

    Post int randallkent

    I hope this helps you

    EDIT:

    solution was found here: gitignore directory exception not working