I'm working on an embedded Linux project. Our build process makes an image that gets flashed to a device. Many of our files require root ownership for the system to work correctly. I ran into a problem when I tried to pull and some of those files were modified - git couldn't write those files, so did reset hard and did sudo pull. Then when I switched branches, it said "unable to unlink..." for all those files, but it switched branches anyway, then when I tried to switch back to the branch it wouldn't let me because I had local changes.
So I'm not doing something right; what is the correct way to deal with this?