Reputation: 207
I'm trying to execute a git remove using wilcards.
git rm -r -f $artname-*-$buildtype
The $artname variable is something like "core" and the $buildtype is something like "SNAPSHOT.jar"
So if there is a file on the remote repo called "core-1.0-SNAPSHOT", it should be removed using the wildcard.
But this doesn't work. The variables do resolve but the wildcard just doesn't seem to work.
This is the error that I'm getting
fatal: pathspec 'core-*-SNAPSHOT.jar' did not match any files
I hope, that someone can help me!
Upvotes: 2
Views: 985
Reputation: 816
A oneliner solution avoiding untracked and .gitignored files could be:
git ls-files $artname-*-$buildtype | tr '\n' '\0' | xargs -0 -L1 -I '$' git rm -r -f '$'
Upvotes: 1
Reputation: 36018
According to the git-rm documentation, possible causes may be:
git
(due to "core-*-SNAPSHOT.jar
" in the error message, it didn't - in your specific case - because it didn't match anything in the directory you're in). Quote the argument to prevent this: git rm "$artname-*-$buildtype"
git
's search behaves as if they don't exist)-r
to work (the docs say so but a simple test with git 2.7.4
shows it actually isn't)Upvotes: 4