title: Removing '.git' directory from git repo?
body: <p>I'm trying to migrate a git repo from Kiln to Github. I can add the new remote just fine, but when I try to push master to the new remote, I get the following error:</p>
  
  <pre><code>Counting objects: 8691, done.
  Delta compression using up to 8 threads.
  Compressing objects: 100% (3000/3000), done.
  remote: error: object a9ee490ac00987835de30bdbc851da5e8d45d28b:contains '.git'
  remote: fatal: Error in object
  error: pack-objects died of signal 13
  error: failed to push some refs to 'git@github.com:Account/repo.git'
  </code></pre>
  
  <p>Commit <code>a9ee490ac00987835de30bdbc851da5e8d45d28b</code> has the following files in it:</p>
  
  <pre><code>.git/
  CHANGELOG.md
  JSONKit.h
  JSONKit.m
  README.md
  </code></pre>
  
  <p>Obviously someone in the past, using <code>hg</code>, checked in a full git repo in a subdirectory.</p>
  
  <p>I'd like to just kill that directory entirely, but am having trouble removing that file from the git history.</p>
  
  <p>The answer in <a href="https://stackoverflow.com/questions/14728751/pushing-a-git-repo-fails-with-error-contains-git">pushing a git repo fails with error: contains &#39;.git&#39;</a> doesn't help, because I've the the repo as a git repo, not a mercurial one.</p>
  
  <p>I tried <code>git filter-branch --index-filter 'git rm -r --cached --ignore-unmatch .git'</code>, but I get the error:</p>
  
  <pre><code>Rewrite 7dbd0970d6c79215d11994b4a9b8091b2e954cfb (326/442)error: Invalid path 'Account/Libraries/ShareKit/Submodules/JSONKit/.git/HEAD'
  error: Invalid path 'Account/Libraries/ShareKit/Submodules/JSONKit/.git/config'
  error: Invalid path 'Account/Libraries/ShareKit/Submodules/JSONKit/.git/description'
  error: Invalid path 'Account/Libraries/ShareKit/Submodules/JSONKit/.git/hooks/applypatch-msg.sample'
  error: Invalid path 'Account/Libraries/ShareKit/Submodules/JSONKit/.git/hooks/commit-msg.sample'
  error: Invalid path 'Account/Libraries/ShareKit/Submodules/JSONKit/.git/hooks/post-update.sample'
  error: Invalid path 'Account/Libraries/ShareKit/Submodules/JSONKit/.git/hooks/pre-applypatch.sample'
  error: Invalid path 'Account/Libraries/ShareKit/Submodules/JSONKit/.git/hooks/pre-commit.sample'
  error: Invalid path 'Account/Libraries/ShareKit/Submodules/JSONKit/.git/hooks/pre-rebase.sample'
  error: Invalid path 'Account/Libraries/ShareKit/Submodules/JSONKit/.git/hooks/prepare-commit-msg.sample'
  error: Invalid path 'Account/Libraries/ShareKit/Submodules/JSONKit/.git/hooks/update.sample'
  error: Invalid path 'Account/Libraries/ShareKit/Submodules/JSONKit/.git/index'
  error: Invalid path 'Account/Libraries/ShareKit/Submodules/JSONKit/.git/info/exclude'
  error: Invalid path 'Account/Libraries/ShareKit/Submodules/JSONKit/.git/logs/HEAD'
  error: Invalid path 'Account/Libraries/ShareKit/Submodules/JSONKit/.git/logs/refs/heads/master'
  error: Invalid path 'Account/Libraries/ShareKit/Submodules/JSONKit/.git/objects/pack/pack-43fac03d375df5c1e380c5e522ba6bcb9b4e1ec1.idx'
  error: Invalid path 'Account/Libraries/ShareKit/Submodules/JSONKit/.git/objects/pack/pack-43fac03d375df5c1e380c5e522ba6bcb9b4e1ec1.pack'
  error: Invalid path 'Account/Libraries/ShareKit/Submodules/JSONKit/.git/packed-refs'
  error: Invalid path 'Account/Libraries/ShareKit/Submodules/JSONKit/.git/refs/heads/master'
  error: Invalid path 'Account/Libraries/ShareKit/Submodules/JSONKit/.git/refs/remotes/origin/HEAD'
  </code></pre>
  
  <p>and history doesn't seem to be changed. I'm at the limit of my git knowledge. Can anyone help?</p>