title: git free disk space by clearing repository history
body: <p>so I'm working with some friends and we are all new to git and one of them committed a large amount of external binary files that slows down the repository, and takes up a large disk-space.</p>
  
  <p>We've just started the project so there's nothing important in it really except a readme file. So what we'd like to do is to Clear the repository history to the current state.</p>
  
  <pre><code>So basicly it looks this:
  
  Head -&gt; A -&gt; B -&gt; C    total disk size 45 MB, 1 file, 300 deleted files
  
  And we want this:
  
  Head -&gt; A              total disk size 1 kB, 1 file, 0 deleted files
  </code></pre>
  
  <p>The obvious solution would be to create a new repository and just copy the readme file into the new repository. However I'd like to learn for educational/curiosity if there's GIT command that can do this.</p>
  
  <p>I've been experimenting with the Rebase command, but it seems like it still keeps old history and their data, which confuses me since if rebaseing doesnt prune data from the repository then you might aswell not use it.</p>
  
  <p>I've been googling some other posts on this issue, and im suspecting that you can't do this with git. However I'd like to confirm that.</p>
  
  <p>And yes it's a remote directory on github</p>
  
  <p>Thanks for any help.</p>
  
  <p>So for my solution i chose to do:</p>
  
  <pre><code>rebase using tortoisegit
  squash all commits
  then using git bash:
  git reflog expire --all --expire-unreachable=now
  git gc --aggressive --prune=now
  git push origin master --force
  </code></pre>
  
  <p>It doesn't seem like the local repository history wants to shrink in disk size. However cloning the repository again shows the desired results and disk size. And the repository log does too.</p>
  
  <p>Thanks for the helpful replies. Interesting Rebase seems very powerful.</p>