Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Ignore uncommitted changes in tracked files with Git
# == IGNORE LOCAL CHANGES
# ignore local changes to repository files or directories
git update-index --assume-unchanged path/to/file/or/directory
# -- ALIAS
# or you can alias it in your ~/.gitconfig
[alias]
au = update-index --assume-unchanged
# == UN-IGNORE LOCAL CHANGES
# update the index and removes the assume-unchanged flag so your changes
# can be committed
git update-index --no-assume-unchanged path/to/file/or/directory
# -- ALIAS
# or you can alias it in your ~/.gitconfig
[alias]
nau = update-index --no-assume-unchanged
# == LIST FILES/DIRS FLAGGED AS `assume-unchanged`
# list files/directories that have been marked as assume-unchanged
# lower-case `h` in first column tells us the file/directory has
# been marked as `assume-unchanged`
git ls-files -v [path/to/directory]
# -- ALIAS
# or alias it in your ~/.gitconfig
# this one passes the list to grep so we can filter on the lowercase letter
[alias]
ignored = !git ls-files -v | grep "^[[:lower:]]"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment