Reputation: 2657
I have added and committed a file ----MY_Session.php
. I left hyphens in the beginning by mistake. Now I want to delete this file, but when I try to run
git rm -----MY_Session.php
it throws the following error.
error: unknown option `---MY_Session.php'
usage: git rm [options] [--] <file>...
-n, --dry-run dry run
-q, --quiet do not list removed files
--cached only remove from the index
-f, --force override the up-to-date check
-r allow recursive removal
--ignore-unmatch exit with a zero status even if nothing matched
I tried all the options listed above but none of them worked.
How can I delete this file?
Upvotes: 1
Views: 537
Reputation: 520968
You can use a glob pattern in your git rm
call to remove your file without specifying the dashes:
git rm '*MY_Session.php'
Of course, you would want to make sure that this pattern won't match any other files besides ----MY_Session.php.
Upvotes: 1
Reputation: 3557
Try
git rm -- ----MY_Session.php
The '--' should stop the parsing of command line options and consider ----MY_Session.php
as the filename.
Upvotes: 3