title: Incremental backups with git bundle, for all branches
body: <p>What is the easiest way to do incremental backups of a git repository with <code>git bundle</code>?</p>
  
  <p>If I just wanted to backup a single branch, I could do something along these lines:</p>
  
  <pre><code>git bundle create foo last-backup..master
  git tag -f last-backup master
  </code></pre>
  
  <p>But what if I want to backup everything (including all branches)?</p>
  
  <hr>
  
  <p>To answer the questions in the comments:</p>
  
  <p>Strictly speaking, I do not need to use the usual Git bundles, as long as the solution satisfies the following properties:</p>
  
  <ul>
  <li><p>Each incremental backup is a single file. I can store it somewhere and subsequent incremental backups do not need to modify this file.</p></li>
  <li><p>The size of the file is approximately equal to the total size of Git commits since the previous backup. Changes in binary files are also efficiently stored.</p></li>
  <li><p>A full backup + all incremental backups since then contain everything that I need to automatically reconstruct the repository, including all branches.</p></li>
  </ul>
  
  <p>(As a naive example, simply constructing a tar archive with recently-changed files in the git repository fails to satisfy the second requirement if, for example, automatic garbage collection has occurred.)</p>
  
  <p>And ideally I would also like to have a system that is idiot-proof:</p>
  
  <ul>
  <li>I can take virtually any full backup of my Git repository, plus all recent incremental backups, and I can simply "pull" everything from the backups and the repository will be up-to-date. In particular, it does not matter if there is a partial overlap between the full backup and incremental backups.</li>
  </ul>
  
  <p>Git bundles satisfy all this very nicely if I only need to handle one branch.</p>