GIT – How to ignore local changed file

If you have a config file or something similar you change on your local computer but dont want it to get marked as “modified”.

Use this command:

git update-index --skip-worktree [filename]

If remote repo gets an update on that file you will get notified about this on a pull.

From stackoverflow:
skip-worktree is useful when you instruct git not to touch a specific file ever. That is useful for an already tracked config file.
Upstream main repository hosts some production-ready config but you would like to change some settings in the config to be able to do some local testing. And you don’t want to accidentally check the changes in such file to affect the production config. In that case skip-worktree makes perfect scene.

If you have skip-worktree on a file and the upstream changes, you get “please commit or stash” when you try to pull

More info here:
http://stackoverflow.com/questions/13630849/git-difference-between-assume-unchanged-and-skip-worktree/13631525

 

Leave a Reply

Your email address will not be published. Required fields are marked *