title: How to handle tracked generated files in git?
body: <p><strong>Background:</strong></p>
  
  <p>We have generated files in our system that need to be committed in their final state (e.g. we can't rely the source (ungenerated) files and make the generated ones on the fly). Since we need the generated files, those files cannot be git ignored.</p>
  
  <p><strong>Problem:</strong></p>
  
  <p>The files trigger a lot of <code>Your local changes to the following files would be overwritten by merge</code> errors from git on checkout and pull commands.</p>
  
  <p>When I pull or checkout, I never care what my files were, I only care about the new files. (Obviously I care a lot about the source file that makes the generated files. I'm happy for merge warnings on the source file, which is kept in a different directory.)</p>
  
  <p>However, when I commit, I want my version to "win" and my generated files to be committed.</p>
  
  <p><strong>Possible solution:</strong></p>
  
  <p>Right now I just run <code>git checkout -- generated-files/</code> before a pull or checkout to reset my generated files and skip any merge errors. It works, but I often forget to do it, and I'd like to automate it if possible.</p>
  
  <p>I looked into a pre-checkout and pre-pull hook, but git doesn't provide them :(</p>
  
  <p><strong>Questions:</strong></p>
  
  <ul>
  <li>Is there a better way to deal with generated files?</li>
  <li>Is there a way to force the <code>git checkout -- generated-files/</code> to run before a pull or checkout?</li>
  <li>How do you deal with generated files in git?</li>
  </ul>