Thursday, April 7, 2022

[SOLVED] How to use git update-index --assume-unchanged <file> with pathspec?

Issue

I have a bunch of auto-generated files I would like to temporarily hide/ignore from my git. I tried this:

git update-index --assume-unchanged '*.gen.*'

but I'm getting a fatal error. Is there a solution to this? Or must I do this file by file?


Solution

This shorter form should work as well :

git update-index --assume-unchanged $(git ls-files -m '**/*.gen.*')

for the reverse :

git update-index --no-assume-unchanged $(git ls-files -v '**/*.gen.*' | grep -Po '^[[:lower:]]+\s+\K.*')


Answered By - Philippe
Answer Checked By - Candace Johnson (WPSolving Volunteer)