0

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.. 
user664481
  • 2,141
  • 9
  • 25
  • 31
  • 1
    Possible duplicate of [Make .gitignore ignore everything except a few files](http://stackoverflow.com/questions/987142/make-gitignore-ignore-everything-except-a-few-files) – Chris Maes Mar 02 '16 at 10:57
  • Sorry, I didn't understand what you mean ? – user664481 Mar 02 '16 at 11:01
  • 1
    @user664481 he means that your question is a duplicate of another question i.e another one has asked this before check the questions and answers in the link provided – Peter Wilson Mar 02 '16 at 11:05

1 Answers1

0

If you do not want ignore patters to apply to all sub-directories but only to the directory .gitignore is in, prefix them with a slash, like !/*.bat.

sschuberth
  • 28,386
  • 6
  • 101
  • 146