git,如何从“ git add”列表中删除太大的文件?

时间:2019-02-26 21:46:48

标签: git github

我正在Linux Ubuntu上使用git。 我不小心将一个大于100 MB的文件添加到我的git中,然后提交,然后尝试推送。 这是我得到的错误:

Username for 'https://github.com': davidechicco
Password for 'https://davidechicco@github.com': 
Counting objects: 19, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (14/14), done.
Writing objects: 100% (19/19), 304.05 MiB | 43.88 MiB/s, done.
Total 19 (delta 8), reused 16 (delta 5)
remote: Resolving deltas: 100% (8/8), completed with 3 local objects.
remote: warning: File temp/resultCollapseRows_datETcollapse_t_1381297037.RData is 71.73 MB; this is larger than GitHub's recommended maximum file size of 50.00 MB
remote: error: GH001: Large files detected. You may want to try Git Large File Storage - https://git-lfs.github.com.
remote: error: Trace: 9084702d401d9df326833f5eb38bdd6a
remote: error: See http://git.io/iEPt8g for more information.
remote: error: File temp/combat_edata_fileName_1381297037.RData is 103.13 MB; this exceeds GitHub's file size limit of 100.00 MB
remote: error: File temp/mergedExpressionSets_1381297037.RData is 102.58 MB; this exceeds GitHub's file size limit of 100.00 MB
To https://github.com/davidechicco/heart-failure-gene-expression-analysis.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://github.com/davidechicco/heart-failure-gene-expression-analysis.git'

现在我想对git停止尝试添加两个大于100 MB的文件。我尝试了许多方法(git reset filenamegit rm --chached filename等),但它们从未成功。我该怎么办?

1 个答案:

答案 0 :(得分:0)

由于您的更改尚未被推送到远程,因此您可以尝试以下步骤。

1)重置上一次提交git reset --hard HEAD^。这将取消暂存文件。

2)现在排除大文件并提交其余文件。

3)按下遥控器。

希望这会有所帮助!