从Git仓库清除文件失败,无法创建新的备份 [英] Purging file from Git repo failed, unable to create new backup

查看:596
本文介绍了从Git仓库清除文件失败,无法创建新的备份的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  git filter-branch --index-filter'我试图从远程仓库中删除一个文件。 git rm --cached --ignore-unmatch Rakefile'HEAD 

但Git抱怨说


无法创建新备份。以前的备份已经存在于refs / original /

强制使用-f

覆盖备份rm:无法删除/.git-rewrite/backup-refs:权限被拒绝

rm:无法删除目录/.git-rewrite:目录不为空


这是我已经删除.git -rewrite目录。



如何删除该文件?这是一个位于我的回购站上的29Mb文件,所以我非常需要删除该文件。



我尝试删除 git rebase -i 中的提交,但显然是因为提交触及了很多不同文件,Git抱怨冲突,我中止安全。

解决方案

您已执行过滤分支操作。在过滤分支之后,Git会保留旧的提交,以防出现问题。

您可以在 .git / refs / original / ... 中找到它们。删除该目录及其中的所有文件,或者使用 -f 标志强制Git删除旧引用。

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


I tried to remove a file from my remote repo by running:

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

But Git complains that

Cannot create new backup. A previous backup already exists in refs/original/
Force overwriting the backup with -f
rm: cannot remove /.git-rewrite/backup-refs : Permission denied
rm: cannot remove directory /.git-rewrite : Directory not empty

This was after I already deleted the .git-rewrite directory on Windows.

How can I remove that file? It's a 29Mb file sitting on my repo, so I quite need to remove the file.

I tried to delete the commit in git rebase -i, but apparently because the commit touched a lot of different files, Git complains of conflicts and I aborted to be safe.

解决方案

You have already performed a filter-branch operation. After filter-branch, Git keeps refs to the old commits around, in case something goes wrong.

You can find those in .git/refs/original/…. Either delete that directory and all files within, or use the -f flag to force Git to delete the old references.

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

这篇关于从Git仓库清除文件失败,无法创建新的备份的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆