0

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

smarber
  • 4,829
  • 7
  • 37
  • 78
Radek Dest
  • 99
  • 1
  • 5

3 Answers3

1

In qq folder, if it’s only has ww.gz.gitkeep and aa.keep or you want all the files in qq folder are version controlled by git, just remove /xtest/* in .gitignore, so the .gitignore looks like:

*.sql
*.gz
*.zip
*.log
!*.keep
!*.gitkeep
!*.dist
!*.dist.*
Marina Liu
  • 36,876
  • 5
  • 61
  • 74
  • Yes, but this is not the point. I need to ignore files except some specyfic ending on .gitkeep, .keep, etc in any directory under /xtest/ – Radek Dest Feb 22 '17 at 12:12
1

By having /xtest/* in your .gitignore, you are instructing Git to ignore xtest/qq. It will never descend in this directory and will never notice that there is some file matching *.keep that you do not want to ignore. Add one of these so that xtest/qq is not ignored:

!/xtest/qq/
!/xtest/*/

That latter un-ignores all directories in xtest, the former only qq.

j6t
  • 9,150
  • 1
  • 15
  • 35
0

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

Community
  • 1
  • 1
Radek Dest
  • 99
  • 1
  • 5