【问题标题】:Node Js, Git, Heroku: Git commits not pushing to git because large file was committed several commits in the past [duplicate]Node Js、Git、Heroku:Git 提交不推送到 git,因为过去提交了几次大文件 [重复]
【发布时间】:2018-08-30 02:28:07
【问题描述】:

见下方编辑

我正在尝试推送到 git,然后推送到 heroku。但是,我认为由于“node_modules”文件夹,我对 git 的推送被中断了。

我得到的错误: 远程:错误:GH001:检测到大文件... 到 git@github...git ! [remote denied] master -> master (pre-receive hook denied) 错误:未能将一些引用推送到 'git@github...git'

大文件是 libsass.lib,在 node_modules 中。

所以我将 node_modules 添加到我的 .gitignore 文件中,如下所示:

node_modules/

我已经运行了这个命令来从 git push 中删除节点模块:

git rm --cached node_modules
git add .
git commit -am "Remove ignored files"

它说它有效,但我尝试再次推送并得到同样的错误。

我的下一步是什么?非常感谢。

编辑。上面附加的重复问题对我的问题没有帮助。这是我所做的,最终按我的预期工作。

我的系统上有 9 个提交无法推送,大概是因为我的第一次推送失败。这将删除内容,因此请备份您的文件。所以我向后工作,使用以下方法删除它们:

git reset --hard HEAD~1 // Destroys the current commit, moving backward by one setp.

一开始,我就为 node_modules 创建了 gitignore 文件。然后我从 git 中删除了它的引用:

git rm -r --cached node_modules
git commit -m "remove node_modules"
git push origin master

我的 heroku 实例在提交方面领先,所以我随后强制推送重置。

git push -f heroku

现在一切都恢复正常了。

【问题讨论】:

    标签: node.js git express heroku


    【解决方案1】:

    尝试从 git 中删除所有内容,然后重新添加所有内容:

    git rm -r --cached .
    git add .
    git commit -m "re-add all for fix"
    

    小心!请记住在执行此操作之前提交所有更改;)

    【讨论】:

    • 这不起作用,但谢谢你的想法。
    • 这有什么帮助?
    猜你喜欢
    • 2020-01-20
    • 2017-02-20
    • 1970-01-01
    • 2013-12-11
    • 2013-12-17
    • 1970-01-01
    • 2021-08-12
    • 1970-01-01
    • 2014-07-13
    相关资源
    最近更新 更多