I want to use git in a particular development environment. MetaTrader 4.
The structure of development directory is fixed, it is of this type:
MQL4
Expert
Files
imagery
Include
Indicators
Some directories come by default with sample files. My idea would be to create directories under of these directories , and to indicate in .gitignore, I wish that only these directories have to be considered by git.
MQL4
Expert
MyGITExperts
Files
imagery
Include
MyGITInclude
Indicators
MyGITIndicators
My idea is a right one ? Are there a better one? How to tell to git, it should take care of only these and these sub-folders ?
Yes there is a way.
From git docs Example to exclude everything except a specific directory foo/bar (note the /* - without the slash, the wildcard would also exclude everything within foo/bar):
$ cat .gitignore
# exclude everything except directory foo/bar
/*
!/foo
/foo/*
!/foo/bar
http://git-scm.com/docs/gitignore
In your case im assuming that MQL4 is inside your project root(where .git file is there)
/*
!/MQL4
/MQL4/*
!/MQL4/Expert/MyGITExperts
!/MQL4/Files
!/MQL4/imagery
!/MQL4/Include/MyGITInclude
!/MQL4/Indicators/MyGITIndicators
This is generally a bad idea when you have large number of such folders