After I run git update-index --assume-unchanged path/to/file
on a particular branch, I'm unable to switch branches using git checkout
.
It throws the following error:
error: Your local changes to the following files would be overwritten by checkout:
path/to/file
Please, commit your changes or stash them before you can switch branches.
Aborting
But both git diff
& git status
tells me there is no difference & there is nothing to commit/stash.
How do I switch out of the branch?
Is there a better alternative to git update-index --assume-unchanged
(other than .gitignore
, because I don't want it to be ignored)? (Same as question 2 @ git update-index --no-assume-unchanged doesn't work)
After some amount of use I now prefer git update-index --skip-worktree
which is a much better alternative to the git update-index --assume-unchanged
.
Check out Difference Between 'assume-unchanged' and 'skip-worktree' for further information.
I also am planning to check out the method specified in this answer to git assume unchanged vs skip worktree - ignoring a symbolic link, which seems to be more defensive approach.