0

We have a folder tree with about 1,000+ xml files at various levels of depth. (the contain game configuration parameters from a 3rd party program).

We have edited about 10 of the files, and want to have a repository that we can fetch (via git clone) so we can overlay our changes on top of a native folder tree.

This is almost working.

Followed the advice in: .gitignore exclude folder but include specific subfolder

What we have done is put .gitignore patters (file globbing) for our windows based tree in to ignore some of the top level folders. E.g

/Scenarios/**
/Model/**
/Directives/**
/ContactReports/**
/Behaviors/**
/PlayerTemplates/**
/PlayerComponents/**

Then later we are trying to add back in some files (which can be done by git add -f , but we would prefer a .gitignore solution).

patterns like:

!/Behaviors/BasilanWP.bgf
!/Behaviors/BasilanFull.bgf

work fine since they are at the top level of the folder tree.

But patterns like the following (at the subfolder level) are still being ignored

!/PlayerTemplates/Weapon/Air_to_Surface/AGM65E.xml
!/PlayerTemplates/Air/Fighter/F-15.xml

I was asked to see if this is a lower/upper case issue unique to windows. Here is the output of git ls-files after we manually forced the files with git add -f

D:\Source\NGTS Scenario>git ls-files
.gitignore
Behaviors/BasilanFly.bgf
Behaviors/BasilanFull.bgf
Behaviors/BasilanJSOW.bgf
Behaviors/BasilanWP.bgf
Behaviors/JSOWBehavior.bgf
Behaviors/LMBCommandPost.bgf
Behaviors/Macros/FlyWaypoint.bgf
Behaviors/MaverickToPoint.bgf
Directives/JSOWDirective.dgf
Directives/MaverickDirective.dgf
PlayerComponents/Weapon/Air-to-Surface/AGM-65E.xml
PlayerComponents/Weapon/Air-to-Surface/AGM-DraperMaverick.xml
PlayerTemplates/Air/Fighter/F-15.xml
PlayerTemplates/Weapon/Air_to_Surface/AGM65E.xml
README.md
Scenarios/Basilan.nscen
Scenarios/BasilanFullJSOW.nscen
Scenarios/BasilanJSOW.nscen
Scenarios/BasilanMacrosWP.nscen
Scenarios/BasilanSOW.nscen

Full .gitignore

/jammers_extra.xml
/sensors_extra_b1.xml
/sensors_extra_b52.xml
/sensors_extra_cafdmo.xml
/sensors_extra.xml
/trafficConfig.xml
/TXA/**
/TacticalVariableGroups/**
/Scenarios/**
/Model/**
/Directives/**
/ContactReports/**
/Behaviors/**
/PlayerTemplates/**
/PlayerComponents/**
!/Behaviors/BasilanWP.bgf
!/Behaviors/BasilanFull.bgf
!/Behaviors/Macros/FlyWaypoint.b
!/Behaviors/BasilanJSOW.bgf
!/Behaviors/BasilanFly.bgf
!/Behaviors/JSOWBehavior.bgf
!/Behaviors/LMBCommandPost.bgf
!/Directives/JSOWDirective.dgf
!/Directives/MaverickDirective.dgf
!/Scenarios/BasilanFullJSOW.nscen
!/Scenarios/BasilanMacrosWP.nscen
!/Scenarios/Basilan.nscen
!/Scenarios/BasilanSOW.nscen
!/Scenarios/BasilanJSOW.nscen
!/Behaviors/MaverickToPoint.bgf
!/PlayerTemplates/Weapon/Air_to_Surface/AGM65E.xml
!/PlayerTemplates/Air/Fighter/F-15.xml
!/PlayerComponents/Weapon/Air-to-Surface/AGM-DraperMaverick.xml
!/PlayerComponents/Weapon/Air-to-Surface/AGM-65E.xml

UPDATE

I have tried a slightly different paradigm and it seems to work better, I also include re-include the relevant folder and not just the file. Which is why this is a different question than: .gitignore exclude folder but include specific subfolder

!/Behaviors/Macros/**
!/Behaviors/Macros/FlyWaypoint.bgf

and

!/PlayerTemplates/Weapon/**
!/PlayerTemplates/Air/**
!/PlayerComponents/Weapon/**

!/PlayerTemplates/Weapon/Air_to_Surface/AGM65E.xml
!/PlayerTemplates/Air/Fighter/F-15.xml
!/PlayerComponents/Weapon/Air-to-Surface/AGM-DraperMaverick.xml
!/PlayerComponents/Weapon/Air-to-Surface/AGM-65E.xml

But I cannot tell if this is due to the forced add, or not.

Dr.YSG
  • 7,171
  • 22
  • 81
  • 139
  • I don't see why folder depth would matter. Are you globally ignoring `*.xml` later in the file? – Adam Jan 24 '19 at 15:48
  • No all I have is folder excludes and file includes. I also don't see why depth matters..... But that is the behavior I am getting. – Dr.YSG Jan 24 '19 at 15:50
  • .bgf files at the subfolder level (which are also xml content) are also being ignored – Dr.YSG Jan 24 '19 at 15:51
  • Probably a casing issue then. I'd take a look at the output of `git ls-files` and check casing between what git's index thinks is the case and what the Windows file system is keeping as the current casing. – Adam Jan 24 '19 at 16:07
  • I added the git ls-files to the main body of the post. – Dr.YSG Jan 24 '19 at 16:41
  • noted! I notice you're using `**`, should we try `*`? – Adam Jan 25 '19 at 00:18
  • Tried “/*” first. “/**” seemed to work, but then I tried more locations and it did not work for those. Go figure – Dr.YSG Jan 25 '19 at 00:23
  • 1
    Possible duplicate of [.gitignore exclude folder but include specific subfolder](https://stackoverflow.com/questions/5533050/gitignore-exclude-folder-but-include-specific-subfolder) – arghtype Jan 25 '19 at 00:24
  • @arghtype I added an update, to explain why that SO article (which I already referenced in the original post) is not enough to answer this question. – Dr.YSG Jan 25 '19 at 15:18

0 Answers0