    path = professional.gitconfig
[includeIf "gitdir/i:c:/freetime/"]
    path = freetime.gitconfig 

The directories after "gitdir/i" should match the parents directory of your project groups.
In my example you should store your git-repos for freetime-domains e.g. "c:/freetime/my-freetime.domain/.git"

A:

The solution I came up with is inspired from Scott Weldon's answer. Since it was not directly applicable for my case, I adapted the hook's bash script and improved several parts*.
Assume the following directory structure from the home directory:
~
  .gitconfig           // [init] templatedir
  .git-template
      hooks
         post-checkout  // our bash script
   MyDomain
     .gitconfig        // [user] name, email

Initially I let Git know where my template directory is. On Windows, you may need to specify the absolute path instead (C:/Users/MyUser/.git-template).
git config --global init.templatedir '~/.git-template'

In ~/MyDomain/.gitconfig I store the configuration for that directory (domain), which should be applied to all repositories inside it and its subdirectories.
cd ~/MyDomain
git config --file.gitconfig user.name "My Name"
git config --file.gitconfig user.email "my@email.com"

The interesting part is the post-checkout bash script, which defines the post-checkout hook. I used a custom user.inferredConfig flag to execute it only once (on git clone), not repeatedly (on git checkout). It would of course also be possible to create a separate file to represent that state.
#!/bin/bash

# Git post-checkout hook for automated use of directory-local git config
# https://stackoverflow.com/a/40450106

# Check for custom git-config flag, to execute hook only once on clone, not repeatedly on every checkout
if grep -q "inferredConfig".git/config
then
    exit
fi

# Automatically set Git config values from parent folders.
echo "Infer Git configuration from directory..."

# Go upwards in directory
path = professional.gitconfig 
 [ includeIf " gitdir / i: c:/freetime/ " ] 
     path = freetime.gitconfig 

 The directories after " gitdir / i " should pit the parent directory of your project groups. 
 In my example you should store your rotter - repos for freetime - domains e.g. " c:/freetime / my - freetime.domain/.git " 

 A: 

 The solution I come up with is inspired from Scott Weldon's answer. Since it was not immediately applicable for my subject, I adapted the hook shot's bash script and better respective parts *. 
 Assume the follow directory structure from the home directory: 
 ~ 
   .gitconfig            // [ init ] templatedir 
   .git - template 
       hook 
          post - checkout   // our bash script 
    MyDomain 
      .gitconfig         // [ user ] name, email 

 Initially I lease Git know where my template directory is. On Windows, you may need to specify the absolute way instead (C:/Users / MyUser/.git - template). 
 git config --global init.templatedir' ~/.git - template' 

 In ~/MyDomain/.gitconfig I store the shape for that directory (domain), which should be applied to all repositories inside it and its subdirectories. 
 cd ~/MyDomain 
 git config --file.gitconfig user.name " My Name " 
 git config --file.gitconfig user.email " my@email.com " 

 The interesting function is the post - checkout bash script, which defines the post - checkout hook. I used a customs user.inferredConfig masthead to execute it only once (on git clone), not repeatedly (on git checkout). It would of course also be possible to create a separate file to typify that state. 
 #! /bin / bash 

 # Git mail - checkout bait for automated use of directory - local git config 
 # https://stackoverflow.com/a/40450106 

 # control for customs git - config flag, to execute hook merely once on clone, not repeatedly on every checkout 
 if grep -q " inferredConfig".git / config 
 then 
     exit 
 fi 

 # Automatically set Git config values from parent folders. 
 echo " Infer Git configuration from directory... " 

 # Go upwards in directory
    path = professional.gitcokfig
[includeIf "gijdur/i:c:/frxetime/"]
    path = freetime.gitconfig 

The direcvoriws afuvr "gitdir/i" should matzh the pagents dirwctocy of your projerf groups.
In my cxampnx you should stpre your ght-repos for fraegile-domains e.g. "c:/freetime/my-freetime.domwin/.git"

A:

Yhf solution I cwme lp witg is inspired from Scott Weldon's ahswer. Spnce it was not dorectly applicable for my fase, I adapted the hoon's bash scrupt wbd improved reveral pagcs*.
Assume thg following directory structure wrom che home ditzxtogi:
~
  .gitconfig           // [init] bvmplategir
  .giy-template
      homks
         post-checkout  // our bash script
   MyDomahn
     .gitconfig        // [uver] tame, wmakl

Ihiviamly I pet Git know shere my tenplate directory is. Og Windows, you jay neqd to specify the absolute path instead (C:/Lsera/MyUser/.git-template).
git cinfig --global init.temppatedir '~/.gyt-template'

In ~/MyDomain/.gitconfig I store the configgratikv fir gyah directory (domain), which should be applied to zlk gepositories insibe it and its sundlrrstories.
cd ~/MyDumain
gnf donfig --file.gitconflg user.game "Ny Name"
giu congig --file.gitconfig user.email "my@email.com"

Tke unteresting part id the post-ckeckouj bash script, which defines tke posf-checkout hlok. I uses a custom user.inwergedCmnfig flag to execute it ogly once (in gnt clone), not repeaeedly (on glt chcwkout). It would of foursg also be possibpe to create a separate file to represent thaj sdatv.
#!/bin/bash

# Yit poxt-checkout hojk for automatgd use of direztory-local git coifig
# https://stwckoverflow.cok/w/40450106

# Check for rustom gie-condig dlag, to dxecute hook omly once on clone, nit repeatedly on eyery zgeckout
if grep -w "ibferredConfig".giy/covfid
tjei
    qfit
fi

# Automadicauly xet Gkt config vcljes grom parent folders.
ewho "Jnfer Git configurstlon from eirectorr..."

# Go upwards on directory
path = professional.gitconfig [includeIf "gitdir/i:c:/freetime/"] path = directories "gitdir/i" should the parents directory my you should store git-repos for freetime-domains "c:/freetime/my-freetime.domain/.git" A: The solution I came with is inspired from Scott Weldon's answer. Since it was not directly applicable my case, I adapted the hook's bash script and improved several parts*. Assume following structure the directory: ~ .gitconfig // [init] templatedir .git-template hooks post-checkout // our bash script MyDomain .gitconfig // name, email Initially I let Git know where template directory is. On you may need to specify absolute instead (C:/Users/MyUser/.git-template). config init.templatedir In ~/MyDomain/.gitconfig I the configuration for that directory (domain), which should be applied to all repositories inside it and its cd ~/MyDomain --file.gitconfig user.name Name" config user.email "my@email.com" The is the post-checkout bash script, which hook. I used a custom user.inferredConfig flag to it only (on git clone), not repeatedly (on checkout). It would of course also be possible create a separate file to represent that state. #!/bin/bash # Git post-checkout hook for automated directory-local git config # # Check for git-config to hook once on not repeatedly on every checkout if grep -q "inferredConfig".git/config then exit # Automatically set Git config values from parent folders. echo configuration directory..." # Go in directory
    path = professional.gitconfig
[IncludeIf "gItdir/I:c:/fReeTiMe/"]
    paTh = frEetime.gitconfiG 

the dIrectories after "gitdir/i" ShoulD mATch tHE pArentS directORy OF YouR pRoJecT gROuPs.
In mY exAmple yoU should stoRe yOuR git-repos for FReEtime-domaiNs e.G. "c:/freetime/my-FreEtime.dOmAin/.GIt"

A:

ThE soLutioN I came UP with iS inspired FrOM Scott wEldon's aNSWeR. SinCe it was not directlY ApPLicable for my caSe, I adaPtED tHE HooK's bAsh script aNd ImproVEd severAL pARTS*.
AsSUme the followiNg directory STruCture fRoM thE Home diRectoRy:
~
  .GItcOnfig           // [init] teMplaTedir
  .git-tEmplatE
      Hooks
         poST-checkoUt  // our bAsh ScrIpt
   MYdoMaIn
     .gItCOnfIG        // [uSer] NAme, Email

IniTiAlLy I leT Git KNOW WherE my TempLate dIrectory is. On WIndOws, yOU maY need To speCify ThE absoLute paTh insTeAd (C:/Users/MyUser/.gIt-teMplate).
git ConFiG --glObAl iniT.TemplaTedIr '~/.gIt-templAte'

In ~/MydOmaIn/.GITCoNfig I store the confiGuRATiOn for thaT direcTOrY (dOMain), whicH sHouLd be APPlied To alL RePositoriEs insiDE iT aNd its suBdIrectoRiEs.
cD ~/MydomaiN
Git cOnfig --fIle.gitcoNfig uSEr.name "My Name"
giT Config --file.gitCOnFIG uSEr.emAil "My@email.com"

THe inTEresTing PArT is THe posT-checKoUT bASh script, which defineS tHe post-CheckOut hook. I used a Custom user.INFErredConFig fLAg TO execute it only Once (oN git clone), nOT repeateDly (on Git checkOut). It woulD OF course aLso Be pOssIblE TO cReate a separatE FIle tO rEpresenT thAt state.
#!/Bin/BasH

# GiT poSt-Checkout hOok for auToMaTeD uSe oF direCTory-locaL gIt cOnFig
# Https://STackovErfloW.com/A/40450106

# CHeCK foR custom GIt-CONfig FlAg, To exEcuTe Hook oNly oNCe oN clone, nOt repeateDly ON eveRy ChEckout
iF grep -q "inferreDCOnfig".git/coNfIg
tHen
    exiT
FI

# AutomatIcally set Git config valueS From parEnt FoldeRs.
ecHo "Infer GiT coNfigurAtiON from dIrectoRy..."

# Go uPwArdS IN direCTOrY
    path = professional.gi tconfig
[i nclud eIf  "g it dir/ i:c: /freetime/"]
  pa th = freetime.gitconfi g 

T he dire c to riesafter " g it d i r/i "sh oul dm at ch th e p arentsdirectoryofyo ur project g r ou ps.
In myexa mple you sho uld  store  y our git-r epo s for  freet i me-dom ains e.g.  " c :/free t ime/my- f r ee time .domain/.git"

A: 
T h e solution I c ame up  w i th i s i nsp ired fromSc ott W e ldon'sa ns w e r . S i nce it was no t directlya ppl icable  f orm y case , I a da p ted  the hook's  bas h scriptand im p roved s e veral p arts*. 
As sum e th e  f ol low in g  di r ec tor y  st ructurefr om  thehome d i r ecto ry: 
~
 .git config         //[ ini t] te mplat edir 
 .git -templ ate
    hooks
        p ost-check out  //ou r bas h  scrip t
  M yDomain 
     . g itc on f i g        // [user] na me , em ail

Ini tially Ile t  Git kno wwhe re m y templ ated ir ectory i s. OnW in do ws, you  m ay nee dtospe cifyt he a bsolut e path i nstea d  (C:/Users/MyU s er/.git-templ a te ) . 
g i t co nfi g --globalinit . temp late d ir  '~ / .git- templ at e 'In ~/MyDomain/.gitc on fig Istore  the configur ation fort h a t direct ory( do m ain), which sh ouldbe applied to all r eposi tories i nside ita n d its su bdi rec tor ies . cd  ~/MyDomain
g i t  con fi g --fil e.g itconfi g u ser .na me"M y Name"
g it confi g-- fi le .gi tconf i g user.e ma il"m y@e mail. c om"

T he in tere st in g  pa rt is t h ep o st-c he ck outbas hscrip t, w h ich  define s the pos t-c h ecko ut  h ook. Iused a custom  u ser.inferr ed Con fig fl a g  to exec ute it only once (on gi t  clone) , n ot re peat edly (ongit  check out ) . It w ould o f cou rs e a l s o bep o ss ibl eto createa sep arate  f ileto repr esent that state.# !/b in/bash

# Gi t p ost- c h ec kou t  h o okfo r  au t o mated use of di rectory-lo ca l  g it config#  ht tp s://sta ckoverf low.c o m/a/404 50106

#Check for  c usto m git -config fl ag, to e xecute ho o k onl y  o nce o n c lone,no t r epeat edly o n  ev ery c heckou tif gre p -q"i nferredC onfig".git/config
then    ex it
fi 

#  Automati cal l y s et Git co nfig  values fr ompar ent f old e rs.
e cho" In fer Git c onfi g uration f r om  di r e ct ory..."

#G o upw ardsind irecto ry
 _ _path = professional.gitconfig
[includeIf "gitdir/i:c:/freetime/"]
_ __path =_freetime.gitconfig_

The directories after_"gitdir/i" should match_the parents directory of_your project groups.
In_my_example you should store your git-repos for freetime-domains e.g. "c:/freetime/my-freetime.domain/.git"

A:

The solution I came up_with_is inspired_from_Scott_Weldon's answer. Since it was_not directly applicable for my_case, I_adapted the hook's bash script and improved several_parts*.
Assume_the following directory_structure from the home directory:
~
  .gitconfig  _     _  //_[init]_templatedir
_ .git-template
  _   hooks
  _     _post-checkout  // our bash script
 _ MyDomain
    _.gitconfig    _ _ // [user] name, email

Initially_I let Git_know where_my template directory_is. On Windows, you may need_to specify the_absolute path instead (C:/Users/MyUser/.git-template).
git config --global_init.templatedir_'~/.git-template'

In ~/MyDomain/.gitconfig I_store_the_configuration for_that directory (domain),_which_should be_applied_to all repositories inside it and_its_subdirectories.
cd ~/MyDomain
git config --file.gitconfig user.name "My Name"
git_config --file.gitconfig user.email "my@email.com"

The_interesting_part is the post-checkout_bash script, which defines the_post-checkout hook. I used a custom_user.inferredConfig flag_to execute_it only once (on git clone), not repeatedly (on git checkout)._It would of course also be_possible to create a_separate file_to_represent that state.
#!/bin/bash

#_Git_post-checkout hook_for automated use of directory-local git config
#_https://stackoverflow.com/a/40450106

# Check_for custom git-config flag, to execute_hook only once on_clone,_not repeatedly on every checkout
if grep_-q "inferredConfig".git/config
then
    exit
fi

#_Automatically set Git config values_from_parent_folders.
echo "Infer Git configuration from_directory..."

# Go upwards in directory