title: git sparse checkout and shallow clone issue with github
body: <p>Want to do a sparse checkout from a git repo (github.com).
  Update (this script works now - trick was to add "/" before pom.xml
  Made this bash script:</p>
  
  <pre><code>#!/bin/sh
  
  export baseUrl=https://github.com/
  export repoAc=spring-projects
  export repo=spring-data-examples
  
  #export baseUrl=https://github.com/
  #export repoAc=tgkprog
  #export repo=testGit
  
  echo "Cd change to correct dir like ~/u/w/s/github/"
  cd ~/u/w/s3/github/
  if [ $? -eq 0 ]; then
      echo OK
  else
      echo"FAIL: bad dir to cd to "
      exit 0
  fi
  echo "Have you edited this script? Else crl -c to stop now"
  echo "you are at dir:"
  pwd
  echo "If exists contents of $repoAc/$repo :"
  ls $repoAc/$repo
  echo "1/2 will delete folder $repoAc/$repo ctrl-c to cancel. Press enter to continue"
  read -rsp $'Press Ctrl-c to cancel or any other key to continue \n' -n1 key
  echo "2/2 will delete folder $repo ctrl-c to cancel. Press enter to continue "
  read -rsp $'Press Ctrl-c to cancel or any other key to continue \n' -n1 key
  mkdir $repoAc
  cd $repoAc
  rm -fR ./$repo
  git init $repo
  cd $repo
  if [ $? -eq 0 ]; then
      echo OK
  else
      echo"FAIL: bad dir to cd to "
      exit 0
  fi
  # TODO if error stop here.
  git remote add origin $baseUrl$repoAc/$repo
  git config core.sparsecheckout true
  echo "elasticsearch/*" &gt;&gt; .git/info/sparse-checkout
  echo "/README.md" &gt;&gt; .git/info/sparse-checkout
  #echo "h/" &gt;&gt; .git/info/sparse-checkout
  #echo "s/" &gt;&gt; .git/info/sparse-checkout
  echo "web/*" &gt;&gt; .git/info/sparse-checkout
  echo "jpa/*" &gt;&gt; .git/info/sparse-checkout
  echo "map/*" &gt;&gt; .git/info/sparse-checkout
  echo "multi-store/*" &gt;&gt; .git/info/sparse-checkout
  echo "/pom.xml" &gt;&gt; .git/info/sparse-checkout
  #echo "!*/pom.xml" &gt;&gt; .git/info/sparse-checkout
  #paths we do not want
  echo "!no1/" &gt;&gt; .git/info/sparse-checkout
  echo "!neo4j/" &gt;&gt; .git/info/sparse-checkout
  echo "!cassandra/" &gt;&gt; .git/info/sparse-checkout
  echo "!solr/" &gt;&gt; .git/info/sparse-checkout
  git pull --depth=1 origin master 
  #   wget https://raw.githubusercontent.com/spring-projects/spring-data-examples/master/pom.xml
  echo "Done $repo"
  ls -al
  </code></pre>
  
  <p>If I remove lines from echo "pom.xml"... and till echo "solr/*" >> .git/info/exclude</p>
  
  <p>I get sub directories:
  bom     elasticsearch   jpa     map     web</p>
  
  <p>But not parent pom.</p>
  
  <p>If I add 
      echo "pom.xml" >> .git/info/sparse-checkout</p>
  
  <p>Then it gets everything (all sub directories). Not sure why?</p>
  
  <p>Update 2:</p>
  
  <p>Earlier was trying :</p>
  
  <pre><code>echo "cassandra/*" &gt;&gt; .git/info/exclude
  </code></pre>
  
  <p>Meaning adding paths I want git not to checkout to the file .git/info/exclude but that file is for add and committing only not for checkout.</p>
  
  <p>For checkout have to add to file .git/info/sparse-checkout like so:</p>
  
  <blockquote>
    <p>&#33;cassandra/</p>
  </blockquote>
  
  <p>The code line:</p>
  
  <pre><code>echo "!cassandra/" &gt;&gt;.git/info/sparse-checkout
  </code></pre>
  
  <p>does that.</p>