我正在构建一个应用程序。我已经成功地将代码检入GitHub几个月了。我达到了需要打包我的应用程序的程度。因此,它被打包成ASAR文件。不幸的是,我没有将文件添加到我的.gitignore文件中。现在,当我尝试检入代码时,我收到以下错误:
GH001: Large files detected. You may want to try Git Large File Storage - https://git-lfs.github.com.
Trace: [ID]
See http://git.io/iEPt8g for more information.
File App/MyApp.asar is 153.32 MB; this exceeds GitHub's file size limit of 100.00 MB
我理解这个问题。但是,我不想实际检查我的ASAR文件。所以,我把它添加到我的.gitignore文件中。然后我尝试将我的代码更改同步到GitHub,我仍然收到上面列出的错误。据我所知,我的代码更改已提交到我的本地分支。但是,由于上面列出的文件已经尝试签入,因此发生了日志卡纸。
我不知道如何疏通果酱。我需要在该提交中进行的代码更改。但是,我不需要ASAR文件。我感到困惑,但是,我不确定如何解开。任何帮助表示赞赏。
答案 0 :(得分:2)
好吧,因为你已经提交了这个更改(因为你想将你的本地提交推送到Github),你需要在推送到远程服务器之前恢复这个更改,检查this answer如何做到这一点( git reset --soft HEAD~
后跟更改(即删除此大文件)和新提交)
答案 1 :(得分:1)
在推送之前,您需要从历史记录中删除该文件。让我们说你添加文件的提交是abc123
。执行git rebase -i abc123^
。这将打开一个编辑器列出该提交,以及从那以后的所有提交。对于包含相关提交的行,请替换&#34; pick&#34;用&#34; e&#34;,然后关闭编辑器。 Git将重播提交,然后停止。输入git rm --cached <filename>
,然后输入git commit --amend
。然后你应该能够推动。
答案 2 :(得分:0)
正如您在错误消息中看到的,git具有文件大小的大小限制。
您必须从存储库中删除大文件 您可以通过以下几种方式实现:
有许多不同的方法可以完全删除文件的历史记录 git,这里有几个选项:
git rebase
假设您有多个提交,而不仅仅是一个提交,您将不得不执行rebase。
# Checkout the commit where you commited the big file
git checkout -b <branch name> <SHA-1>
# Amend the commit
git rm <file>
git commit --amend --no-edit
# Rebase your previous branch onto this new commit, starting from the old-commit
git rebase --preserve-merges --onto <branch name> <old-commit> <original branch name>
git rebase -i/-p
)交互式rebase允许您以手动方式修改历史记录。 请保留,因为它是一个手动工作,很难在太多的提交中做到这一点。
// X is the number of commits you wish to modify
git rebase -i HEAD~X
打开编辑器后
选择 s
进行squash =它会将所有提交合并为一次提交。
选择 e
来编辑所需的提交,git将在此提交时停止重新定位,然后删除您的文件并再次提交(git ammend
用于任何给定的提交只有最后一个)。
示例:
# rebase has stopped at the given commit. edit it and remove our file
# same as you will do if it was the latest commit without using rebase
git rm <file>
git commit --amend --no-edit
# once the file removed - continue to the other commits if needed.
git rebase --continue
git filter-branch --index-filter \
'git rm --cached --ignore-unmatch <file>'
这将在您选择的所有提交范围内执行给定命令(X
,在此代码段中删除历史记录中不需要的文件:
git filter-branch --index-filter \
'git rm --cached --ignore-unmatch <file>' HEAD~X..HEAD
但是bfg-repo-cleaner是比git filter-branch
答案 3 :(得分:-2)
答案 4 :(得分:-2)
当您更改.gitignore
文件时,请不要忘记清除缓存,如下所示:
git rm --cached your_file
另外,如果你的大文件仍有问题,我建议你看一下:Git non-cached file being uploaded to Github
希望这有帮助!