Search code examples
gitversion-controlgitignore

git ignores too many files


I have files structure:

$ ls xtest/
arch.gz.keep  
raq.gz.keep
qq

$ ls xtest/qq/
ww.gz.gitkeep
aa.keep

My .gitignore

/xtest/*
*.sql
*.gz
*.zip
*.log
!*.keep
!*.gitkeep
!*.dist
!*.dist.*

git status files untracked:

xtest/.gitkeep
xtest/.keep
xtest/arch.gz.keep

For me i need also to have untracked:

xtest/qq/ww.gz.gitkeep
xtest/qq/aa.keep

git --version 1.9.1 on Ubuntu 14.04


Solution

  • I found solution, the point is that i want to ignore every file/path starting from dir 'xtest' -> '/xtest/' except some files placed anywhere in /xtest/ How do I add files without dots in them (all extension-less files) to the gitignore file?

    Maybe for somebody it will help: To ignore any file in dir /xtest/ but not any directory and not some specific files:

    /xtest/**/*
    !/xtest/**/*/
    /xtest/**/cache/*
    *.sql
    *.gz
    *.zip
    *.log
    !*.keep
    !*.gitkeep
    !*.dist
    !*.dist.*
    

    subdirs of cache/ will be ignored always, even if there is *.keep, *.gitkeep, etc but not ignored in first depth into cache/ and almost all files will be ignored in other dirs (into /xtest/) except *.keep, *.gitkeep, etc