tags:

views:

1280

answers:

2

How to provide file pattern rather a particular file in git-update-index --remove command?

A: 
# for i in pattern; do git-update-index --remove $i; done

Wouldn’t something like that serve your purpose? (I have never worked with git-update-index, though.)

Bombe
This would only affect files in the working copy.
bdonlan
+1  A: 

Something like

git update-index --remove -- $(git ls-files '*.c')
araqnid
Be sure to quote your wildcard in the ls-files clause so it's not interpreted by the shell.
bdonlan
gah, I should have known better :|
araqnid
Thanks for the solution, it worked. But when I am using it inside a filter branch statement with the pattern in a local variable "pattern" its not working, pattern='*.c'git filter-branch --index-filter 'git update-index --verbose --remove -- "$(git ls-files -- $"(pattern)")"' HEAD
kaychaks
$"(pattern)" tries to expand a variable called "(pattern)" which isn't what you want.The additional quotes around the $(git ls-files...) invocation are probably wrong too--- they'll convert the output to a single argument to git update-index, newlines and all, not what you want.For instance, I did this in a test repo which is kind of like what you need:git filter-branch --index-filter 'git update-index --verbose --force-remove --remove -- $(git ls-files -- p4-*)' -- --branches(It blows away all "p4-*" files). If you have filenames with spaces, there may be trouble.
araqnid
i have space inside file names. I am fetching them to the update-index command in a loop but it is not recognizing the file now,FILE="some file.c"git filter-branch --index-filter 'git update-index --verbose --remove "$FILE"' HEAD. It is working fine as long as i give the exact file name instead of the substitution var.
kaychaks