Skip to content

Instantly share code, notes, and snippets.

@fullkomnun
Created October 30, 2019 21:25
Show Gist options
  • Save fullkomnun/79c5bb7e557a338564fdd6f1a9aae02a to your computer and use it in GitHub Desktop.
Save fullkomnun/79c5bb7e557a338564fdd6f1a9aae02a 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 | xargs -0 git update-index --skip-worktree $ git ls-files -z | 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