由于文件大小过大,无法进行git push

5

我之前在本地进行了多次提交,但没意识到github不允许上传超过100MB的文件,现在有4或5个提交需要推送,但无法完成。请问该如何处理?

$ git push
Counting objects: 114, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (96/96), done.
Writing objects: 100% (114/114), 48.24 MiB | 467.00 KiB/s, done.
Total 114 (delta 54), reused 0 (delta 0)
remote: Resolving deltas: 100% (54/54), completed with 10 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: bc3c170ddc8fcb18b4fd112e6036e0f7
remote: error: See http://git.io/iEPt8g for more information.
remote: error: File app/release/app-release.apk is 139.72 MB; this exceeds GitHub's file size limit of 100.00 MB
remote: error: File app/release/app-release.apk is 135.97 MB; this exceeds GitHub's file size limit of 100.00 MB
remote: error: File app/release/app-release.apk is 105.54 MB; this exceeds GitHub's file size limit of 100.00 MB
To https://github.com/montao/adventure.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://github.com/montao/adventure.git'

 git status
On branch master
Your branch is ahead of 'origin/master' by 8 commits.
  (use "git push" to publish your local commits)

nothing to commit, working tree clean

1
你为什么要将apk推送到Github? - TheOni
@TheOni 这就是我想要撤销的。那是一个错误。 - Niklas Rosencrantz
2个回答

14
你可以简单地重置你的状态,不包括apk文件(你可能不应该提交它们)。
你可以简单地这样做:
git reset origin/master

保留你的更改但重置所有提交记录。


或者,对于那些使用 main 而不是 master 的人来说:git reset origin/main - Cyrille

4

曾经,我将一堆全尺寸的照片提交到了我的存储库中。以下是我用来完全从历史记录中删除它们的方法。

首先,我复制了存储库。这样,如果我弄错了什么,我就有了备份。最好不要跳过这一步。 :-)

然后,我进行了交互式变基(rebase -i),从意外添加照片的原始提交之前开始。我删掉了照片的提交。

在变基之后,我运行了

git reflog expire --expire=now --all
git gc --aggressive --prune=now

在你的情况下,也需要将 app/releases/ 添加到你的 .gitignore 文件中。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接