140

次のコマンドを実行して、リモートリポジトリからファイルを削除しようとしました。

git filter-branch --index-filter 'git rm --cached --ignore-unmatch Rakefile' HEAD

しかし、Gitはそれを不平を言います

新しいバックアップを作成できません。以前のバックアップはすでにrefs/original /に存在し
ます-fでバックアップを強制的に上書きします
rm:/.git-rewrite/backup-refsを削除できません:許可が拒否されました
rm:ディレクトリを削除できません/.git-rewrite:ディレクトリが空ではありません

これは、Windowsで.git-rewriteディレクトリをすでに削除した後のことです。

そのファイルを削除するにはどうすればよいですか?これは私のリポジトリにある29Mbのファイルなので、ファイルを削除する必要があります。

でコミットを削除しようとしましたgit rebase -iが、コミットが多くの異なるファイルに触れたため、Gitが競合を訴え、安全のために中止しました。

4

4 に答える 4

257
于 2011-06-19T18:37:05.343 に答える
26

Use this command to remove original backup:

git update-ref -d refs/original/refs/heads/master

Here is gist I used to filter-branch my git repo: https://gist.github.com/k06a/25a0214c98bc19fd6817

于 2015-12-09T11:19:30.650 に答える
4

I had the same problem and the answer above didn't fix it. There was no .git/refs/original/ directory left. The solution for me was to delete the .git/packed-refs file.

于 2015-04-23T23:39:33.520 に答える
2

filterbranchコマンドに力を追加します。

于 2011-06-19T18:31:34.177 に答える