Reputation: 9796
We are using VSCode in our project, we have .vscode/tasks.json
tracked on the server just to make sure everyone is aligned with the same configuration.
Since I wanted to add new tasks (just for me), I made this file skip-worktree
with git update-index --skip-worktree .vscode/tasks.json
.
But even though this file was committed only once on the remote, when we created the project, and never got an update, the git still says Your local changes to the following files would be overwritten
when I try to merge or rebase my current branch with main
.
Why does git want to overwrite the file even though it wasn't changed on the remote? Is ther e anyway to make git be smarter to try to overwrite my file only when it is necessary (by showing it as a conflict)?
Upvotes: 1
Views: 65
Reputation: 1328122
I am a big proponent of wrapper scripts (build, run, …) in a project repository: all my projects have the same scripts, with the same name, regardless of the technology.
That way, the onboarding is easier: clone then build.
All those wrapper scripts call a tools/init
script, which can (among other things) copy a .vscode/tasks.tpl.json
(template file maintained for everybody in Git) into a .vscode/tasks.json
, ignored by Git through a .gitignore
rule and that you can modify at your heart's content: it is not versioned.
The next init call will not copy again .vscode/tasks.tpl.json
, since .vscode/tasks.json
already exists.
The first time you clone the repository and call either build or run, the environment is initialized, including .vscode/tasks.json
Upvotes: 0