git ignore local changes code example

Example 1: git ignore local file changes

# To skip local changes to files managed by git
$ git update-index --skip-worktree path/to/file
# To restore normal git behaviour
$ git update-index --no-skip-worktree path/to/file

# assume-unchanged can also be used, it's designed for local files that DON'T change
# git reset --hard will drop files ignored through assume-unchanged
$ git update-index --assume-unchanged path/to/file
$ git update-index --no-assume-unchanged path/to/file

Example 2: how to remove file changes in git

git clean -df
git checkout -- .

Example 3: git remove my local changes and pull from master

git reset --hard 

Tags:

Misc Example