How to provide file pattern rather a particular file in git-update-index --remove
command?
views:
1280answers:
2
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
2009-05-15 12:27:19
This would only affect files in the working copy.
bdonlan
2009-05-15 18:12:58
Be sure to quote your wildcard in the ls-files clause so it's not interpreted by the shell.
bdonlan
2009-05-15 18:12:37
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
2009-05-16 22:57:50
$"(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
2009-05-16 23:39:37
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
2009-05-17 08:05:21