I thought I could remove files from Git pretty easily with essentially :
$ git rm myfile.php $ git commit -m "Removing a file"
But I was getting this error upon commit : "Could not open input file myfile.php"
This is how I got it to work. The Git Cheat Sheet (http://cheat.errtheblog.com/s/git) described this as "Commit the absence of myfile.txt to the project"
$ git rm --cached myfile.php $ git commit -m "Removing a file"
There are 3 Comments
Re: Getting "git rm" to work
do you have a pre-commit hook?
i have a php pre commit hook that was breaking it
changed
exec("php -l " . escapeshellarg($file), $lint_output, $return);
to
$return = 0;
if (file_exists($file)) {
exec("php -l " . escapeshellarg($file), $lint_output, $return);
}
Pre-commit hook and "git rm"
Yes, there's a good chance I had a pre-commit hook when I ran into this. Most of my PHP projects do a "php -l" before the commit -- apparently just like you!
Thanks!
Add check for file existence
Yes, per the comment above, adding the check for file existence to my pre-commit hook script removed this error.
Here is where my pre-commit hook is :
/.git/hooks/pre-commit-php-l.php