Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/github/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
从git中删除大文件_Git_Github_Github For Windows - Fatal编程技术网

从git中删除大文件

从git中删除大文件,git,github,github-for-windows,Git,Github,Github For Windows,这是我上一篇文章的后续文章。 我正试图删除我提交给git的一个大文件。根据我在上一篇文章中给出的建议,我试着 git filter-branch --force --index-filter "git rm --cached --ignore-unmatch folder/Unconfirmed 866711.crdownload" --prune-empty --tag-name-filter cat -- --all 按照上面的命令,我尝试推送所有更改 git push origin --

这是我上一篇文章的后续文章。 我正试图删除我提交给git的一个大文件。根据我在上一篇文章中给出的建议,我试着

git filter-branch --force --index-filter "git rm --cached --ignore-unmatch folder/Unconfirmed 866711.crdownload" --prune-empty --tag-name-filter cat -- --all
按照上面的命令,我尝试推送所有更改

git push origin --force --all
但是,我得到了在使用过滤器分支之前显示的相同错误

或者,我也试过了

git add --all

git filter-branch -f --index-filter "git rm --cached --ignore-unmatch folder/Unconfirmed 866711.crdownload" HEAD
但是,我得到以下信息

Cannot rewrite branches: Your index contains uncommitted changes.
我不确定我是否错过了任何命令或标志。有什么建议吗

无法重写分支:索引包含未提交的更改

您的工作目录中有未提交的更改,即为提交检查git状态输出而进行的更改。如果愿意,可以提交这些更改,也可以在执行过滤器分支命令后使用and保留这些未提交的更改

如果您不想要未提交的更改,那么可以执行硬重置

git reset --hard HEAD
正如下面的评论和GitHub帮助中提到的,不建议在筛选器分支之前使用stash

警告:如果在保存更改后运行git筛选器分支,则 无法使用其他隐藏命令检索您的更改。 在运行git筛选器分支之前,我们建议取消任何更改 你已经成功了

因此,如果要保留未提交的更改,请提交更改。然后继续执行filter branch命令。 “筛选分支”命令缺少单引号,无法解释要删除的文件名中的空格

git filter-branch -f --index-filter "git rm --cached --ignore-unmatch 'folder/Unconfirmed 866711.crdownload'" HEAD

我建议不要在git过滤器分支中使用git stash。“filter branch”命令可以对所有引用(包括stash ref)进行操作,并可以在此过程中销毁隐藏。@torek,是否可以在filter branch中排除覆盖隐藏引用?是:如果指定要重写的引用列表,例如git filter branch-branchA branchB,则只重写这些分支。但我认为更简单、更实用的方法是先提交,然后过滤,然后退出最后一次提交。@SaurabhPBhandari正如您所建议的,我提交了所有更改,然后是过滤分支。我得到以下警告:Ref'refs/heads/master'未更改警告:Ref'refs/remotes/origin/master'未更改警告:Ref'refs/stash'未更改。你能建议下一步该做什么吗?我可以将更改推送到存储库吗?@Natasha,警告表明您的命令没有更改任何引用,即没有成功。
git filter-branch -f --index-filter "git rm --cached --ignore-unmatch 'folder/Unconfirmed 866711.crdownload'" HEAD