I have a configuration file abc.cfg
with local changes for my environment. To prevent pushing local configs to the remote, I use git update-index --skip-worktree abc.cfg
on the file.
Now the upstream has changed abc.cfg
with global updates that I need. So I first did --no-skip-worktree abc.cfg
, did git stash
on it, pulled the upstream, and proceed with git stash apply
on the file.
Now there's merge conflicts on abc.cfg
. I tried to resolve it, and do git update-index --skip-worktree abc.cfg
again, but this time it says:
fatal: Unable to mark file scripts/app.js
How should I apply back my local changes without including it in the commits?
The is a corner case which could prevent
git skip-worktree
to work as intended in case of merge conflict.When the sparse checkout feature is in use, "
git cherry-pick
" and other mergy operations lost theskip_worktree
bit when a path that is excluded from checkout requires content level merge, which is resolved as the same as the HEAD version, without materializing the merge result in the working tree, which made the path appear as deleted.This has been corrected in Git 2.19 (Q3 2018) by preserving the
skip_worktree
bit (and not materializing the file in the working tree).See commit 2b75fb6 (27 Jul 2018) by Elijah Newren (
newren
).See commit 92203e6 (27 Jul 2018) by Ben Peart (
benpeart
).(Merged by Junio C Hamano --
gitster
-- in commit e4095da, 15 Aug 2018)