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?
CodePudding user response:
Following the suggestion from @torek I came up with these commands:
Hide .gen.
files
git status -s | grep '.gen.' | cut -c 4- | xargs -I FILE git update-index --assume-unchanged FILE
git status -s
list files in short formatgrep '.gen.'
filter list to files containing.gen.
anywhere in the pathcut -c 4-
cut the start of each string to remove theM
xargs -I FILE git update-index --assume-unchanged FILE
loops through each of the files and executes the git command
List ignored files
git ls-files -v | grep "^[a-z]"
Unhide all files
git ls-files -v | grep "^[a-z]" | cut -c 3- | xargs -I FILE git update-index --no-assume-unchanged FILE
This won't work for files that are not yet in the repo but it is enough for my use case.
CodePudding user response:
This shorter form should work as well :
git update-index --assume-unchanged $(git ls-files -m '**/*.gen.*')