[ GIT ] — ignore local file

When a file is committed, it won’t be affected by the .gitignore system. I changes some files but I don’t want to see at working tree.

Fortunately GIT has a way to solve this issue git update-index . But there are two options for this command — assume-unchanged and — skip-worktree. Although they bit looks similar, but their goal are different.

— assume-unchanged : you only don’t see at working tree, but still do anything with GIT

— skip-worktree : GIT doen’t touch skip-worktree files.

Eg: when you pull, you must checkout the files at assume-unchanged list if config

♦- add, remove or view list files skip with — skip-worktree

git update-index --skip-worktree <file_to_ignore> 
git update-index --no-skip-worktree <ignored_file>
git ls-files -v | grep ^S

♦- add, remove or view list files skip with — assume-unchanged

git update-index --assume-unchanged <file_to_ignore> 
git update-index --no-assume-unchanged <ignored_file>
git ls-files -v | grep ^h

♦- shortcut commands

# skip-worktree 
alias gusk='git update-index --skip-worktree '
alias gunosk='git update-index --no-skip-worktree '
alias glsk='git ls-files -v | grep ^S '
# assume-unchanged 
alias guas='git update-index --assume-unchanged '
alias gunoas='git update-index --assume-unchanged '
alias glas='git ls-files -v | grep ^h '

Originally published at www.uixcrazy.com.

One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.