title: How do I exclude files from git archive?
body: <p>Given a simple test repository with a single commit with two files, <code>a</code> and <code>b</code>, I can get a list of specific files:</p>
  
  <pre><code>$ git ls-files a
  a
  </code></pre>
  
  <p>Or a list of all files excluding specific files:</p>
  
  <pre><code>$ git ls-files . ':!b'
  a
  </code></pre>
  
  <p>I can create an archive of specific files:</p>
  
  <pre><code>$ git archive HEAD a | tar tf -
  a
  </code></pre>
  
  <p>But I cannot create an archive of all files excluding specific files:</p>
  
  <pre><code>$ git archive HEAD . ':!b' | tar tf -
  a
  b
  </code></pre>
  
  <p>The option of using an archive of specific files is not an option for me in my real repository, as it exceeds the maximum command line argument length.</p>
  
  <p>I know I can store the list of files to exclude in <code>.gitattributes</code> via the <code>export-ignore</code> attribute, but the list is dynamically generated. I can automatically change the file, but changes do not get picked up until after another commit.</p>
  
  <p>Is there some other invocation that works without requiring another commit?</p>