title: Why does Zipping the same content twice gives two files with different SHA1?
body: <p>I have run into a strange problem with git and zip files. My build script takes a bunch of documentation html pages and zips them into a docs.zip I then check this file into git. </p>
  
  <p>The problem I am having is that every time I re-run the build script and get a new zip file the new zip file has a different SHA1 than the previous run. My build script is calling the ant zip task. However manualy calling the macOSX zip from the Mac OS X shell gives me a different sha1 if I zip up the same directory twice. </p>
  
  <p>Run 1: </p>
  
  <pre><code>zip foo.zip *
  openssl sha1 foo.zip 
  rm foo.zip 
  </code></pre>
  
  <p>Run 2: </p>
  
  <pre><code>zip foo.zip *
  openssl sha1 foo.zip
  </code></pre>
  
  <p>Run 1 and run2 give different SHA1 even though the content did not change between runs. In both cases zip prints out exactly the same files being zipped it does not indicate that any OS specific files like .DS_Store are being included in the zip file. </p>
  
  <p>Is the zip algoritm deterministic? If run on the same content will it produce exactly the same bits? if not why not? </p>
  
  <p>What are my choices for zipping the files in a deterministic way? There are thousands of them in the zipped up file, I don't expect those files to change much. I know that git will zip up any files you checkin but the motivation to zip them is to just keep the mass of them out of the way.</p>