My specific situation: Java program with an About class that is imported by a couple of other classes in the project. When compiling, the About.java file is auto-regenerated but otherwise it's never touched.
I don't want to remove the file from the repo and .gitignore it because that means when some one initially pulls down the repo, the About.java file is not there. Admittedly, this isn't the end of the world given that it will generate on their first compilation, but still, for that time being there are errors in the IDE, etc. I just don't like that. I want some compilable version of the file to be there, even though I don't care what its specific contents are (since they'll be overwritten upon compilation anyway).
After a compilation and regeneration in my local branch, I want git to ignore the fact that the file was changed vis-a-vis 'git status', 'git diff', 'git add -i', etc. so that my compilation's changes to it are not cluttering up my real check-ins.
After a compilation and regeneration in my local branch, I want to be able to switch to another branch and have git not worry about the fact that my current local branch has a changed About.java file. Just throw away the changes and move on to whatever About.java is in the branch I'm switching to.
I've tried using a combination of 'git update-index skip-worktree' on the file and then switching branches using 'git checkout -f' but it doesn't work. The checkout -f to switch branches complains that the entry for the About.java file is "not uptodate. Cannot merge."
The man for checkout -f says: "When switching branches, proceed even if the index or the working tree differs from HEAD. This is used to throw away local changes.
When checking out paths from the index, do not fail upon unmerged entries; instead, unmerged entries are ignored."
That sounds like exactly what I want, but when I use it in the above scenario it still very much fails upon an unmerged entry. Why is that?
BTW, I've tried messing with 'git update-index --assume-unchanged' also, but still I can't get all three of the desired behaviors (base version that stays in the repo, when I make/check-in changes ignore the fact that that one file has changed, and allow me to change branches and truly do not fail because that one file is an unmerged entry) in play together
At present, I have behaviors 1 and 2 with skip-worktree and then when I want to change branches, I have to manually reset that one file first. Works, but it's very annoying to have to always do that. Is there any way to make checkout -f do what it's man page says it's supposed to do and get to the complete behavior that I want?