I have a similar situation like this: Link Basically, I have a file called settings_data.json in my repository. I have --skip-worktree flag set on this file, so that if I make changes on my local machine, I don't accidentally push those changes to production. This is a normal approach for a situation like this, I understand. The problem is, that this file also changes on production independently. In this situation, when I make a pull, I don't want to pull changes for this file on my local repository. I want to completely ignore it. Is there an opinionated approach for a situation like this?
EDIT: I found a "partial solution" based on this answer. I wrote a bash script for git alias, that pulls from remote without comitting, then check out files that has conflict and finally commit changes. But this also pulls changes that I don't want to have locally. I still need something to completely ignore files I don't want to change locally.
This is my alias: pullbase = "!f() { git pull base main --no-commit; git diff --name-only --diff-filter=U --relative | xargs git checkout HEAD; git commit --no-edit; }; f"
I think I finally found a solution for my specific case. This is my git alias:
pullbase = "!f() { git pull base main --no-commit; git diff --name-only --diff-filter=M --stat base/main..HEAD templates config/settings_data.json | xargs git checkout HEAD; git log --pretty=format:'%s' -n 1 base/main | git commit -F -; }; f"
Basiscally what I do is I pull changes from my "base" repository, I check out files that are different between HEAD and remote, then I checkout to HEAD only files I don't want to update. Lastly, I use last commit message from remote and commit my local repo. I hope someone finds this as usefull.