I'm using git, and made a small commit followed by a large one. I decided to use
git rebase -i HEAD~2
error: cannot stat 'filename': Permission denied
Could not apply sha1 for later commit... initial line of text for that commit
I've only ever seen this error on Windows and what it seems to mean is that something blocked git from modifying a file at the moment when it tried to a apply a patch.
Windows tends to give processes exclusive access to files when it shouldn't really be necessary, in the past virus checkers have been one source of suspicion but I've never proved this conclusively.
Probably the easiest thing to do is to abort and try again, hoping that it doesn't happen the next time.
git rebase --abort
You can attempt to use
git apply and knowledge of what commit git was actually trying to do before doing a
git rebase --continue but in all honesty I wouldn't recommend this. Most of the times I've seen this tried there's been a better than evens chance that something gets accidentally missed or messed up.