This took me some time to figure out, as most results to googling «ignore committed file» sent me on a wild goose chase with most answers on StackOverflow really answering how to remove a previously committed file and ignore it.
My scenario is not like that. I have a build folder checked out along with other folders, and the files in this build folder is updated by build scripts when I develop. I am not interested in checking in these results, as these files change all the time, but I do want to keep them in the repo. Unfortunately, putting the file patterns in .gitignore does not work (which was what sent me googling in the first place).
It turns out you can modify your local index to ignore changes to tracked files in the repo by issuing a flag called «–assume-unchanged» when calling update-index. So, given that you have a file foo.exe that you want to keep unchanged on the remote repo, issue the following command
git update-index --assume-unchanged foo.exe