Node Js,Git,Heroku:Git承诺不推送git,因为大文件过去曾提交了几次提交[重复]

问题描述 投票:-1回答:1

这个问题在这里已有答案:

见下面的编辑

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

我得到的错误:remote:错误:GH001:检测到大文件...要git @ github ... git! [远程拒绝] master - > master(pre-receive hook拒绝)错误:无法将某些引用推送到'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个回答
0
投票

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

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

小心!记得在这之前提交所有更改;)

© www.soinside.com 2019 - 2024. All rights reserved.