2

问题

我不小心将我的数据集添加到我的提交中。当我推送提交时,它给了我标准文件大小错误(数据集文件超过 100MB)。我使用 恢复了之前的提交git revert,并且只添加了我的 ipython 笔记本和一些图像文件。

现在,当我推送我的提交时,它仍然会厌倦推送数据集文件

使用git diff --stat origin/master我发现要推送的文件:

agconti@agconti-Inspiron-5520:~/my_dev/github/US_Dolltar_Vehicle_Currecny$ git diff --stat origin/master

 .ipynb_checkpoints/US_Dollar_Vehicle_Currency-checkpoint.ipynb | 1972 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 CountryNumbers_indexConti.xlsx                                 |  Bin 0 -> 22762 bytes
 Italian Trade/US_Dollar_Vehicle_Currency.ipynb                 | 1972 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 Italian Trade/images/3_year_exchange_rate_volitlity.png        |  Bin 0 -> 11808 bytes
 Italian Trade/images/Currency_usage_breakdown_top20.png        |  Bin 0 -> 404666 bytes
 Italian Trade/images/Currency_usage_observations_top20.png     |  Bin 0 -> 274964 bytes
 Italian Trade/images/Currency_usage_trade_value_top20.png      |  Bin 0 -> 211274 bytes
 Italian Trade/images/Exchange_rate_volitlity_top20.png         |  Bin 0 -> 345899 bytes
 Italian Trade/images/prop_xm_top20.png                         |  Bin 0 -> 258254 bytes
 Italian Trade/images/rate_derive_activity_top20.png            |  Bin 0 -> 214196 bytes
 README.md                                                      |    2 +-
 US_Dollar_Vehicle_Currency.ipynb                               |  809 --------------------------------
 images/3_year_exchange_rate_volitlity.png                      |  Bin 11808 -> 0 bytes
 images/Currency_usage_breakdown_top20.png                      |  Bin 404666 -> 0 bytes
 images/Currency_usage_observations_top20.png                   |  Bin 292532 -> 0 bytes
 images/Currency_usage_trade_value_top20.png                    |  Bin 224008 -> 0 bytes
 images/Exchange_rate_volitlity_top20.png                       |  Bin 361868 -> 0 bytes
 images/exporter_economic_strength_top20.png                    |  Bin 0 -> 166575 bytes
 images/exporter_trade_health_top20.png                         |  Bin 0 -> 277557 bytes
 images/prop_xm_top20.png                                       |  Bin 275777 -> 0 bytes
 images/rate_derive_activity_top20.png                          |  Bin 228728 -> 0 bytes
 libpeerconnection.log                                          |    0
 22 files changed, 3945 insertions(+), 810 deletions(-)

没有数据集文件。即便如此,他们仍然受到推动。

如何让 git 停止推送数据集文件?

下面看一下错误信息:

Delta compression using up to 8 threads.
Compressing objects: 100% (27/27), done.
Writing objects: 100% (30/30), 279.15 MiB | 389 KiB/s, done.
Total 30 (delta 7), reused 3 (delta 0)
remote: Error code: c4fe7114933ad585dc5027c82caabdaa
remote: warning: Error GH413: Large files detected.
remote: warning: See http://git.io/iEPt8g for more information.
remote: error: File ForConti_AllItalianImportsVCP.raw is 987.19 MB; this exceeds GitHub's file size limit of 100 MB
remote: error: File italian_imports.csv is 1453.55 MB; this exceeds GitHub's file size limit of 100 MB
remote: error: File italian_imports_random_10percent.csv is 138.30 MB; this exceeds GitHub's file size limit of 100 MB
To https://github.com/agconti/US_Dollar_Vehicle_Currency
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://github.com/agconti/US_Dollar_Vehicle_Currency'

我试过的

我怎样才能看到我将要使用 git 推送什么?

如何将 Git 存储库恢复到以前的提交?

4

3 回答 3

6

因为您使用git revert了 ,所以这些文件仍然在您的存储库中被引用。听起来这是您的基本顺序:

git add <a bunch of stuff including big files>
git commit                  # creates a commit including the unwanted files
# realize mistake
git revert HEAD             # this creates a new commit on top of the previous one,
                            # that simply undoes all the changes in the previous commit
# now trying to push

如果您在master自(或介于两者之间)错误提交和错误提交的恢复中没有其他提交(换句话说,您的图表看起来像(其中 Z 是最后一次好的提交):

 .....Z--A--A' <- master

那么以下应该会有所帮助:

 git reset --hard Z

这会将您的分支以及您的工作目录和索引重置master回,这意味着它看起来像是错误的提交,并且从未发生过还原。Z

如果在上面的点之后还有其他提交A,你需要使用, 并删除与和git rebase -i Z对应的两行。AA'

如果A您想要保留其他更改(即不仅仅是在那里提交的大文件),您将需要使用该git rebase -i路由,并标记Aedit. 这将导致rebase在刚刚完成提交时停止A,然后您可以这样做:

 git rm --cached <big files>                # remove the files from your index
 git commit --amend                         # fix up the last commit
 git rebase --continue                      # let rebase finish up the rest

完成上述任一操作后,git push应该可以再次进行...

于 2013-07-18T19:59:55.223 回答
1

revert命令将撤消操作记录为常规提交。大文件仍在历史中。也许您需要从历史记录中完全删除错误提交和恢复的提交。和

git rebase -i origin

应该打开一个编辑器——如果你只是删除指示错误提交和恢复的行,你应该重新启动并运行。有关交互式 rebase 的更详细描述,请参阅Git 书籍

于 2013-07-18T20:00:11.567 回答
0
git filter-branch --force --index-filter 'git rm --cached --ignore-unmatch italian_imports.csv' --prune-empty -- --all
于 2013-07-18T21:07:43.943 回答