当我尝试推送到 Heroku 存储库时,我收到此错误。
我已经在 gitconfig 中设置了autocrlf = false
,但这个问题仍然存在。我也在这里尝试过这个解决方案,但它不起作用。
git 是否可能仍在使用旧的配置设置?
如果是,那么我该如何刷新它?
C:myapp>git push heroku
To git@heroku.com:myapp.git
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'git@heroku.com:myapp.git'
To prevent you from losing history, non-fast-forward updates were rejected
Merge the remote changes (e.g. 'git pull') before pushing again. See the
'Note about fast-forwards' section of 'git push --help' for details.
<小时 />尝试git pull heroku master
时:
warning: no common commits
remote: Counting objects: 215, done.
remote: Compressing objects: 100% (147/147), done.
remote: Total 215 (delta 82), reused 132 (delta 62)Receiving objects: 79% (170/
Receiving objects: 100% (215/215), 1.49 MiB | 107 KiB/s, done.
Resolving deltas: 100% (82/82), done.
From heroku.com:myapp
* branch master -> FETCH_HEAD
Auto-merging start.php
CONFLICT (add/add): Merge conflict in start.php
Auto-merging src/appinfo.txt
CONFLICT (add/add): Merge conflict in src/appinfo.txt
Auto-merging result.php
CONFLICT (add/add): Merge conflict in result.php
Auto-merging landhere.php
CONFLICT (add/add): Merge conflict in landhere.php
Automatic merge failed; fix conflicts and then commit the result.
<小时 />尝试git push heroku -f
时:
F:myapp>git remote add heroku git@heroku.com:myapp.git
F:myapp>git push heroku
Counting objects: 41, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (40/40), done.
Writing objects: 100% (41/41), 1.36 MiB | 12 KiB/s, done.
Total 41 (delta 0), reused 0 (delta 0)
-----> Heroku receiving push
! Heroku push rejected, no Cedar-supported app detected
To git@heroku.com:myapp.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'git@heroku.com:myapp.git'
尝试使用
git push heroku main
而不是
git push heroku master
原因:因为 git 的默认起始分支已从 master
更改为 main
,这就是为什么您的 git 命令无法识别master
分支并给您"ref"错误的原因。
在 Heroku 中,推送到主分支时可能会遇到问题。我只需要使用
git checkout -b masterbranch
然后使用
git push heroku masterbranch
请尝试上述操作!
此错误意味着上游存储库已提交,如果您要推送,这些提交将丢失。先做一个"git pull"进行合并,然后再推送。
执行以下命令:
$ rake assets:precompile
$ git add .
$ git commit -m "Add precompiled assets for Heroku"
$ git push heroku master
来源: http://ruby.railstutorial.org/ruby-on-rails-tutorial-book
我是唯一一个在我的应用程序上工作的人,并且只在我的桌面上工作,所以我设法获得 dev 之上的 heroku 存储库的可能性没有意义。但!我最近让一位 Heroku 支持代表查看我的 heroku 帐户,以查找涉及 gem 安装的缓存问题,他更改了一些导致 heroku 返回与上面列出的错误相同的错误的内容。只用了git pull heroku master
。然后我发现代表的微小变化并自己恢复了它。
我遇到了同样的问题。
在我的分支中,解决方案称为"testBranchSuper",我使用
git checkout -b main
然后我用了
git push heroku main
如果要将提交推送到 Git 存储库,请确保已合并来自其他分支的所有提交。
合并后,如果无法推送提交,请使用带有 -f
的 push 命令:
git push -f origin branch-name
其中origin
是远程存储库的名称。
确保推送正确的分支。我不在master
上,一直想知道为什么它抱怨:P
如果我不是唯一一个使用某人的初学者"FULL STACK OVERMEGASUPER EASY AND COOL"Udemy 课程,我正在写这篇文章(为了添加到可能的解决方案列表中(。我有以下错误:
remote: -----> Build
remote: Running build
remote:
remote: > shop@1.0.0 build /tmp/build_cb8c8cb5
remote: > cd frontend && npm install && npm run build
remote:
remote: sh: 1: cd: can't cd to frontend
remote: npm ERR! code ELIFECYCLE
remote: npm ERR! errno 2
remote: npm ERR! shop@1.0.0 build: `cd frontend && npm install && npm run build`
remote: npm ERR! Exit status 2
remote: npm ERR!
remote: npm ERR! Failed at the shop@1.0.0 build script.
remote: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
remote: ! Push rejected to shop.
remote:
To https://git.heroku.com/shop.git
! [remote rejected] main -> main (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/shop.git'
我尝试了其他用户提供的几乎所有内容。尽管如此,没有什么能解决我的问题。然后,我终于爱管闲事,可以查看日志(出于某种原因,我立即求助于互联网(。
解决方案如下:
- 打开 package.json 并删除"脚本"中的"构建"行;
- git add .
- git 提交 -您的消息-
- Git push Heroku Main
这一次,构建成功了。这是一个非常愚蠢的错误。终端告诉我出了什么问题,但我没有注意到。
,强制推动是有效的。
git push heroku master --force
这适用于从当前分支推送的提交被删除的情况(提交已推送到远程存储库(。
对于从谷歌搜索到达这里的任何人,使用相同的错误消息。另请注意,如果您使用的是 sqlite3,则可能会遇到问题
https://devcenter.heroku.com/articles/sqlite3
在我的情况下,清除构建包有效 heroku buildpacks:clear
只需使用以下命令更改 Heroku 的分支:
git checkout -b main
我按照以下步骤操作,它对我有用。
首先,请获取您的(本地(更改的副本.
然后:
$ git fetch heroku
$ git reset --hard heroku/master
然后尝试
git push heroku
发生这种情况还有一个微妙的原因。如果向应用添加了一些新程序包或更新了现有程序包,请记住还要更新要求.txt文件。
pip freeze > requirements.txt
然后,您可以继续执行推送存储库的常规过程
git add .
git commit -m "Some changes"
git push heroku master
我正在 freeCodeCamp 学习本教程并遇到了同样的问题。
命令
git push heroku master
不再有效,因为 GitHub 自 2020 年 10 月起使用更具包容性的语言,并将其分支语言更改为使用 main 而不是 master。
此命令改为工作:
$ git push heroku main
我收到此错误,因为我在我的要求中添加了一行.txt文件中有错误:
simplejson=2.6.2
只有一个=
,应该有两个:
simplejson==2.6.2
更正此问题修复了错误。
您似乎没有完全了解最新状态。你需要做一个 git 拉取和"--rebase",或者让它合并到你的集合中。
在此之后,您应该能够推送,因为这将是不会删除历史记录的"快进"更改。
编辑:示例命令列表
git pull
git push
另一个问题可能来自反引号的使用,编译器(丑陋者(不支持反引号。
要修复它,请将config.assets.js_compressor = :uglifier
替换为 config.assets.js_compressor = Uglifier.new(harmony: true
(。
学分:https://medium.com/@leog7one/how-to-fix-execjs-runtimeerror-syntaxerror-unexpected-character-on-heroku-push-deployment-c0b105a64655
如果你的 heroku 项目根目录与你的 git 分支根目录位于不同的目录中,请使用以下命令:
git subtree push --prefix path/to/root heroku master
就我而言,我执行以下操作来解决此问题:
- 删除包锁.json
-
run npm install
-
git add .
-
git commit -m 'dependencies updated.'
-
git push
-
git push heroku main
如果要从代码不在主分支上的 git 存储库进行部署,则需要运行:
git push heroku HEAD:master
如果您已经推送到 heroku,则可能需要运行:
git push heroku HEAD:main --force
来源: https://fullstackopen.com/es/part3/implementacion_de_la_aplicacion_en_internet#politica-de-mismo-origen-y-cors(可以用多种语言阅读(
只需将分支切换到 main
,然后从 Heroku 远程中删除项目。从本地删除所有分支,仅使用一个"主"。
供参考:
https://help.heroku.com/O0EXQZTA/how-do-i-switch-branches-from-master-to-main
对我来说,它在设置全局用户名/电子邮件后开始工作。
要设置全局用户名/电子邮件配置:
- 打开命令行。
- 设置您的用户名:
git config --global user.name"FIRST_NAME LAST_NAME">
- 设置您的电子邮件地址:
git config --global user.email"MY_NAME@example.com">
- 提交
git commit -m "comment">
推送到 heroku git push heroku master
这可能是由于过时的yarn.lock文件
只需运行以下命令
yarn install
git add yarn.lock
git commit -m "Updated Yarn lockfile"
git push heroku master
就我而言,我的软件包名称无效。我无法立即发现错误代码,因为我没有向上滚动足够远,但错误是:
remote: $ NPM_CONFIG_PRODUCTION=false npm install --prefix client && npm run build --prefix client
remote: npm ERR! code EINVALIDPACKAGENAME // <-- this was hard to find
remote: npm ERR! Invalid package name "react-loader-spinne r": name can only contain URL-friendly characters
此外,请确保您的分支是干净的,并且没有任何未暂存的内容您可以使用 git 状态进行检查存储或提交更改然后运行 comand<</p>
我遇到了类似的问题,本地构建工作正常,但是当我将我的分支推送到 heroku 上时,它将无法构建。问题是我的 package.json 中有一些 devDependencies,在 npm 安装期间没有安装,这导致我的构建失败。
如果需要访问不同构建包中或在运行时在 devDependencies 下声明的包,则可以将NPM_CONFIG_PRODUCTION=false or YARN_PRODUCTION=false
设置为跳过修剪步骤。
你也可以将你的开发依赖项移动到依赖项中...
我遇到了类似的错误。我修复我的是如何将命令从 $ git push heroku master
更改为 $ git push heroku main
.
事实证明,我的 git 存储库在主分支而不是主分支中。因此,如果您使用错误的分支,它会影响您。
我遇到了同样的问题,我通过这样做解决了它:
heroku config:set DISABLE_COLLECTSTATIC=1
这是一个关于python 3.7的Django项目。