I'm trying to run this command:
git filter-branch --force --index-filter 'git rm --cached --ignore-unmatch filename.js' --prune-empty --tag-name-filter cat -- --all
but I keep getting this error:
fatal: ambiguous argument 'rm': unknown revision or path not in the working tree . Use '--' to separate paths from revisions, like this: 'git <command> [<revision>...] -- [<file>...]'
It depends on the shell you are using.
On Windows, with msysgit for instance, see issue 477:
Single quotes do not have a special meaning with CMD. Do not expect that they work the same as with a POSIX shell. Call filter-branch like this:
git filter-branch --commit-filter "GIT_COMMITTER_NAME=void GIT_AUTHOR_NAME=void GIT_COMMITTER_EMAILfirstname.lastname@example.org GIT_AUTHOR_EMAILemail@example.com; git commit-tree \"$@\"" HEAD
git filter-branch --commit-filter "GIT_COMMITTER_NAME=void \ GIT_AUTHOR_NAME=void \ GIT_COMMITTER_EMAILfirstname.lastname@example.org \ GIT_AUTHOR_EMAILemail@example.com; \ git commit-tree \"$@\"" HEAD
Each argument to the various
...-filtersneeds to be a single string. That string is saved as a shell variable.
Windows 10, PyCharm, GitPython, same command as in question.
"inside the string and it worked!
Cannot create a new backup. A previous backup already exists in refs/original/ Force overwriting the backup with -f rm: cannot remove '/YOURPATH/.git-rewrite/backup-refs': Permission denied rm: cannot remove directory '/YOURPATH/.git-rewrite': Directory not empty. — Oct 03, 2014 at 14:05
/YOURPATH/.git-rewritefolder. — Oct 03, 2014 at 14:38
So make sure 'git rm --cached --ignore-unmatch filename.js' is considered a string in the shell you are in.VonC, thank you so much. It saved me who knows how much more time it could be. Windows 10, PyCharm, GitPython, same command as in question. Simply changed
"inside the string and it worked! — May 30, 2019 at 12:47
External links referenced by this document:
Local articles referenced by this article: