Git to ignore all files except certain files

时间:2016-03-02 10:55:28

标签: git

I want git to keep track certain files only, so i wrote this gitignore file. In this file i tell git to ignore all the files except .ps1,.bat,.sql and .tab.I placed this gitignore file in root local working directory. Now the problem was, if the keep track files in subdirectory (BatchFile subdirectory), git will ignore them which i believed due to * . How to correct it ?

*
!*.ps1
!*.bat
!*.sql
!*.tab

My folder directory structure

Main
    BatchFile
    DB_Objects
              Table
              View
              and etc.. 

1 个答案:

答案 0 :(得分:0)

如果您不希望忽略模式应用于所有子目录,但仅应用于.gitignore目录,请在其前面加上斜杠,如!/*.bat