Search code examples
gitgitignore

Github ignore all but include one folder


In .gitignore file I want to ignored all files and folders excluding only one folder. I try something like this but no success.

 # Ignore everything:
/**

# Except for :
!/charts/

Any suggestions? Thanks


Solution

  • To ignore everything you should use: *. Like this:

    # ignore everything:
    *
    
    # except:
    !charts/
    !charts/*
    

    You should keep excepting all directories under charts/*/...