title: Creating a sparse and shallow clone of a git repository results in error: trying to write non-commit object
body: <p>I want to create a sparse and shallow clone of a git repository at a certain tag.</p>
  
  <p>This is what I am currently doing:</p>
  
  <pre><code>git init avatica-tmp
  
  cd avatica-tmp
  
  git remote add origin https://github.com/apache/calcite-avatica/
  
  git config core.sparsecheckout true
  
  echo "core/src/main/protobuf/*" &gt;&gt; .git/info/sparse-checkout
  
  git pull --depth=1 origin rel/avatica-1.10.0
  </code></pre>
  
  <p>It works correctly, but throws an error:</p>
  
  <pre><code>remote: Counting objects: 531, done.
  remote: Compressing objects: 100% (381/381), done.
  remote: Total 531 (delta 147), reused 280 (delta 51), pack-reused 0
  Receiving objects: 100% (531/531), 963.03 KiB | 233.00 KiB/s, done.
  Resolving deltas: 100% (147/147), done.
  From https://github.com/apache/calcite-avatica
   * tag               rel/avatica-1.10.0 -&gt; FETCH_HEAD
  fatal: update_ref failed for ref 'HEAD': cannot update ref 'refs/heads/master': trying to write non-commit object fe4f0b4ea3e2ee4f3b2e82329363a7945493a8c9 to branch 'refs/heads/master'
  </code></pre>
  
  <p>I get this error with Git 2.11.0 on Ubuntu 17.04 and Git 2.13.2.windows.1 on Windows 10 64-bit. I am not attempting to clone to a mapped drive.</p>
  
  <p>What causes this error and how do I avoid it?</p>