git - 如何从我当前的提交中删除一个太大的文件

标签 git git-commit

当我执行以下操作时:

git add *
git commit -m "msg"
git push origin develop

我收到以下错误:

Counting objects: 25, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (24/24), done.
Writing objects: 100% (25/25), 46.43 MiB | 2.49 MiB/s, done.
Total 25 (delta 13), reused 0 (delta 0)
remote: Resolving deltas: 100% (13/13), completed with 11 local objects.
remote: error: GH001: Large files detected. You may want to try Git Large File Storage - https://git-lfs.github.com.
remote: error: Trace: ffe0c9f32d9cde4cedfc1f4713eb82b9
remote: error: See http://git.io/iEPt8g for more information.
remote: error: File tags is 282.99 MB; this exceeds GitHub's file size limit of 100.00 MB
To https://mygithubrepo
 ! [remote rejected] develop -> develop (pre-receive hook declined)
error: failed to push some refs to 'https://mygithubrepo'

然后我从硬盘中删除了文件“tags”,但每次尝试推送时,我都会遇到同样的错误。该文件从未被推送到我的存储库,所以我只需要从当前提交中删除它。我尝试了很多事情,但每次都以同样的错误告终。有帮助吗?

当我做的时候

git ls-files

文件“tags”甚至没有显示在列表中。但它仍然试图 push 它?

最佳答案

这应该有效:

git rm --cached <big_file>
git commit --amend .

这将从跟踪中删除该文件,然后修改之前的提交以不包含该文件。

关于git - 如何从我当前的提交中删除一个太大的文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49076876/

相关文章:

git - 在 git checkout 中间意外停止了命令我该如何恢复

Gitlab 运行程序根据提交消息有条件运行

git - 列出为特定 git commit 修改的文件

git - Dart 包依赖于 git repo 的子目录

git - 预测将在 git push 中推送多少数据

linux - 根据文件扩展名过滤 git diff-tree 的输出

Git 恢复失败

git - 如何将修改后的提交推送到远程 Git 存储库?

git - 使用 "fixup!"或 "squash!"之间有什么真正的区别吗?

git 查看两个任意分支之间的提交计数差异