0

I am trying this solution: Can't push to GitHub because of large file which I already deleted

In an elevated cmd (and with Visual Studio closed) I am giving:

git filter-branch --index-filter 'git rm -r --cached --ignore-unmatch <TheFolderIWantToDelete>' HEAD

or:

git filter-branch --index-filter 'git rm -r --cached --ignore-unmatch <TheFolderIWantToDelete>' -f HEAD

and in both cases I get the following error: Access is denied

What exactly is being denied access to? TheFolderIWantToDelete? And how can I find out what exactly denies the access?

The command result

UPDATE: I also take "Access is denied" when I specify a different existing directory. But when I specify a different non existing directory, I take "The system cannot find the file specified.". So something prevents access to TheFolderIWantToDelete.

GeoDev
  • 1
  • 4
  • The command doesn't seem to have anything to do with github or git push? What is the exact error you're getting? – evolutionxbox Sep 09 '22 at 11:43
  • We haven't pushed yet. The error is Access is denied. – GeoDev Sep 09 '22 at 12:10
  • 3
    Are you on Windows? (looks like), do you have the repo open in another command window? Or In Explorer? To find out what's blocking the deletion, try running ProcMon to see what errors you're getting or use handle to list which files are opened (and by whom): https://learn.microsoft.com/en-us/sysinternals/downloads/handle?WT.mc_id=DOP-MVP-5001511 and https://learn.microsoft.com/en-us/sysinternals/downloads/procmon?WT.mc_id=DOP-MVP-5001511 – jessehouwing Sep 09 '22 at 12:55
  • 1
    If you're using WSL, the file may also be locked from the linux side. Try shutting down WSL in that case. `wsl --shutdown` – jessehouwing Sep 09 '22 at 12:57
  • I am not using WSL. – GeoDev Sep 09 '22 at 13:43
  • Can you please copy the complete error message and paste it in your question ? – LeGEC Sep 09 '22 at 13:57
  • The complete error message is already in the question: Access is denied. – GeoDev Sep 09 '22 at 14:02
  • @GeoDev so it doesn't say _what_ access is denied? Is git throwing the error? That surely can't be the complete error – evolutionxbox Sep 09 '22 at 14:03
  • This exact error is the only thing under the command I run. – GeoDev Sep 09 '22 at 14:13
  • 1
    It's likely you have something open that is locking a folder or file that you are trying to rewrite. Note it may even be your command prompt if you aren't in the root of the repo. If all else fails maybe reboot your machine. – TTT Sep 09 '22 at 17:04
  • *What exactly is being denied access to?* is a good question. It's not coming *from Git* though: Git's errors are prefixed with a lot of verbosity, usually including the prefix `fatal:`. – torek Sep 09 '22 at 17:12
  • Nothing else is open. I have already rebooted. – GeoDev Sep 09 '22 at 17:27
  • There could be something wrong about the access rights on some files or directories, either in your repo (in the worktree) or under the `.git/` directory. A test which shouldn't take too long : try cloning your repo locally, and run `git filter-branch ...` in that clone. – LeGEC Sep 09 '22 at 19:08
  • I cloned the repo locally but with the same result. – GeoDev Sep 09 '22 at 19:55

1 Answers1

0

This worked (with double quotes):

git filter-branch --index-filter "git rm -r --cached --ignore-unmatch ProjectReleases" HEAD

GeoDev
  • 1
  • 4