w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Stop tracking files in git (without deleting them)

Turns out the answer is pretty simple.

Just run git update-index --skip-worktree [path] to stop git from tracking changes to any given file.

If you ever do make changes to that file which you want to commit with git, run git update-index --no-skip-worktree [path] to make git start tracking that file again

FYI: The original answer suggested using git update-index --assume-unchanged but it turns out that option can break behavior when switching branches, while --skip-worktree is intended for this exact scenario. More details here: Git - Difference Between 'assume-unchanged' and 'skip-worktree'

© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.