Is there a way to tell git to always ignore and discard local changes for a file that has been committed?
I've read about these options but neither appears to be what I want.
The scenario is that there's a particular file which needs to exist in order to compile, but some tool often does a pointless change to it during build (either stamping a version number or adding/removing insignificant whitespace). (It's not a "generated file" -- it does contain unique important content. It just also gets modified by a build tool. Unfortunately fixing the build process is not an option.)
As a result, it is always locally modified, and I always have to remember to revert it before committing or pulling or I'll get conflicts or create commits with those same pointless unrelated changes in it. (I always get the conflicts when checking out another branch, for example, partly because different instances of the pointless changes get baked in along with intentional changes in each branch.)
What I want is for git to always overwrite the local file with the upstream copy whenever it changes upstream (regardless of whether there are local changes or not), and then continue doing so without needing to toggle it again.
(I literally never make intentional changes to one such file. Another file I do very rarely make intentional changes to, but I'm ok with having to remember to unset a 'discard local' flag in that case and setting it again afterwards, and I don't care if I forget and the intentional changes are lost -- that's better than a checkout failing.)