Reputation: 68
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?
Upvotes: 0
Views: 1098
Reputation: 26472
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.*')
Upvotes: 1
Reputation: 68
Following the suggestion from @torek I came up with these commands:
.gen.
filesgit 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 the M
xargs -I FILE git update-index --assume-unchanged FILE
loops through each of the files and executes the git commandgit ls-files -v | grep "^[a-z]"
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.
Upvotes: 1