Background:
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.
Problem:
The files trigger a lot of Your local changes to the following files would be overwritten by merge
errors from git on checkout and pull commands.
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.)
However, when I commit, I want my version to "win" and my generated files to be committed.
Possible solution:
Right now I just run git checkout -- generated-files/
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.
I looked into a pre-checkout and pre-pull hook, but git doesn't provide them :(
Questions:
- Is there a better way to deal with generated files?
- Is there a way to force the
git checkout -- generated-files/
to run before a pull or checkout? - How do you deal with generated files in git?