Skip to content

Instantly share code, notes, and snippets.

@fullkomnun
Last active October 30, 2019 21:29
Show Gist options
  • Save fullkomnun/661da179b9871f906ed8867891fc7f66 to your computer and use it in GitHub Desktop.
Save fullkomnun/661da179b9871f906ed8867891fc7f66 to your computer and use it in GitHub Desktop.
Git ignore beyond .gitignore
# There are times when you want to ignore files that are already managed with Git locally.
# This can be achieved using `git update-index` command.
# For ignoring entire paths recursively, one can use the following commands:
git ls-files -z <path> | xargs -0 git update-index --skip-worktree
git ls-files -z <path> | xargs -0 git update-index --assume-unchanged
# Aliases can be created to ease usage:
# checks for any files flagged w/ --skip-worktree alias
check="git ls-files -v|grep '^S'"
# add --skip-worktree flag to file
skip() { git ls-files -z "$@" | xargs -0 git update-index --skip-worktree; git status; }
# remove --skip-worktree flag from file
unskip() { git ls-files -z "$@" | xargs -0 git update-index --no-skip-worktree; git status; }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment