未能将一些参考文献推送到git@heroku.com

时间:2012-03-20 20:28:56

标签: git heroku git-svn

当我尝试将文件推送到heroku rep时,我收到此错误。

我已经在gitconfig中设置了autocrlf = false但是这个问题仍然存在。 我也试过这个解决方案here 但没有收获。

任何建议都可能是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'

33 个答案:

答案 0 :(得分:32)

此错误意味着上游存储库已提交了如果您要推送将丢失的提交。首先进行“git pull”合并,然后再次推送。

答案 1 :(得分:14)

执行此操作:

$ 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

答案 2 :(得分:8)

我是唯一一个在我的应用程序上工作但只能从我的桌面上工作的人,因此我设法将heroku存储库放在dev上面的可能性没有意义。但!我最近有一个Heroku支持代表查看我的heroku帐户以查找涉及gem安装的缓存问题,并且他更改了导致heroku返回与上面列出的错误相同的错误。只需要git pull heroku master。然后我发现代表们做了很小的改变并自己将其还原。

答案 3 :(得分:4)

尝试使用

git push heroku main

代替

git push heroku master

原因: 因为 git 的默认起始分支已从 master 更改为 main 这就是为什么您的 git 命令无法识别 master 分支并给您 ref 错误

答案 4 :(得分:3)

我遇到了同样的问题,解决方法是

在我的分支中称为“ testBranchSuper”

我使用

git checkout -b main

然后我用

git push heroku main

答案 5 :(得分:3)

如果你想在git仓库上推送提交,请确保你已经合并了其他分支的所有提交。

合并后如果无法推送提交,请使用带-f

的push命令

git push -f origin branch-name

origin是您的远程仓库的名称。

答案 6 :(得分:2)

在Heroku中,您可能无法推送到master分支。 我只需要使用

启动一个新分支
var input = ["apple", "banana", "pear", "kiwi", "orange"],
    output = input.map(function(elem, index)
    {
        return index > 0 ? input.slice(0, index + 1).join('/') : elem;
    });

console.log(JSON.stringify(output, null, '\t'));

然后使用

进行推送
git checkout -b masterbranch

请尝试以上操作!

答案 7 :(得分:1)

对我来说,它是在设置了全局用户名/电子邮件后开始工作的。

设置全局用户名/电子邮件配置:
1.打开命令行。
2.设置您的用户名:

git config --global user.name "FIRST_NAME LAST_NAME"
  1. 设置您的电子邮件地址:
git config --global user.email "MY_NAME@example.com"
  1. 提交
git commit -m "comment"
  1. 推送到heroku
git push heroku master

BOOM!它有效(对我来说至少)

答案 8 :(得分:1)

对我来说,强制推送操作有效。

git push heroku master --force

Case - 当从当前分支推送的提交被删除时(提交被推送到远程存储库)。

答案 9 :(得分:1)

对于从谷歌搜索到达此处的任何人都有相同的错误消息。另请注意,如果您使用的是 sqlite3

,则可能会出现问题

https://devcenter.heroku.com/articles/sqlite3

答案 10 :(得分:1)

确保你正在推动正确的分支。我不在master,并一直想知道为什么抱怨:P

答案 11 :(得分:1)

我按照以下步骤操作,对我有用。

  • 请复制您的(本地)更改。 fetch heroku reset --hard heroku/master 然后尝试推送heroku'。

答案 12 :(得分:1)

您似乎并不完全是最新的。你需要做一个git pull和“--rebase”或者让它合并到你的集合中。

在此之后,你应该能够推动,因为这将是一个“快进”的改变,不会删除历史。

编辑:示例命令列表

git pull
git push

答案 13 :(得分:0)

我正在关注 this tutorial from freeCodeCamp 并遇到了同样的问题。

$ git push heroku master 不再有效,因为 GitHub is using more inclusive language as of October 2020 并更改了他们的分支语言以使用 main 而不是 master

这个命令可以代替:

$ git push heroku main

答案 14 :(得分:0)

当我尝试 git pull heroku master 时,出现错误 fatal: refusing to merge unrelated histories

所以我尝试了 git pull heroku master --allow-unrelated-histories 并且它对我有用

答案 15 :(得分:0)

我在本地构建工作正常的情况下也遇到了类似的问题,但是当我将分支推送到heroku时,它将无法构建。问题是我的package.json中有一些devDependencies,在npm install期间没有安装,这导致我的构建失败。

如果您需要访问在其他buildpack或运行时在devDependencies下声明的软件包,则可以设置NPM_CONFIG_PRODUCTION=false or YARN_PRODUCTION=false跳过修剪步骤。

还可以将devDependencies移至依赖项...

答案 16 :(得分:0)

如果您的heroku项目根目录与git分支根目录不在同一目录中,请使用以下命令:

git subtree push --prefix path/to/root heroku master

答案 17 :(得分:0)

只需将分支切换到main,它肯定会工作,并从Heroku远程删除项目。从本地删除所有分支,仅使用一个“主”。

以供参考:https://help.heroku.com/O0EXQZTA/how-do-i-switch-branches-from-master-to-main

答案 18 :(得分:0)

此外,请确保您的分支是干净的,并且没有未分级的内容 你可以用git status检查 存放或提交更改 然后运行命令

答案 19 :(得分:0)

如果我不是唯一一个使用某人的“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'

我尝试了其他用户提供的几乎所有内容。尽管如此,没有什么能解决我的问题。 然后,我终于有足够的精力查看日志(出于某种原因,我立即求助于互联网)。

解决方法如下:

  1. 打开 package.json 并删除“scripts”中的“build”行;
  2. git 添加。
  3. git commit -您的消息-
  4. git push heroku main

这一次,构建成功。这是一个非常愚蠢的错误。终端告诉我出了什么问题,但我没有注意到。

答案 20 :(得分:0)

在heroku上部署Django应用时遇到了这个问题。

就我而言,requirements.txt,Procfile和runtime.txt文件位于子目录中。将它们移至存储库的根目录即可解决该问题。

Heroku专门在根目录中寻找requirements.txt来设置python环境。


P.S:

如果heroku在子目录中的wsgi文件存在之前无法访问,请通过以下线程-

解决

How can I modify Procfile to run Gunicorn process in a non-standard folder on Heroku?

答案 21 :(得分:0)

您应该检查一些东西

  1. 分支母版是在您的git存储库中创建的
  2. 配置user.name和user.email
  3. 推入前拉动

我希望它能与您合作

答案 22 :(得分:0)

我遇到了同样的问题,并通过执行以下操作解决了该问题: heroku config:set DISABLE_COLLECTSTATIC=1 这是python 3.7上的django项目

答案 23 :(得分:0)

对于我来说,我的包裹名称无效。我无法立即获取错误代码,因为我没有滚动足够远,但是错误是:

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

答案 24 :(得分:0)

还有另一个微妙的原因可能导致这种情况发生。如果您向应用程序中添加了一些新软件包或更新了现有软件包,请记住也要更新您的requirements.txt文件。

pip freeze > requirements.txt

然后,您可以按照通常的过程来推送存储库

git add .
git commit -m "Some changes"
git push heroku master

答案 25 :(得分:0)

可能是由于 yarn.lock文件已过期

只需运行以下命令

yarn install
git add yarn.lock
git commit -m "Updated Yarn lockfile"
git push heroku master

答案 26 :(得分:0)

另一个问题可能是由于使用了反引号,编译器(uglifier)不支持反引号。

要解决此问题,请将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

答案 27 :(得分:0)

请检查是否有2个锁文件(如果有),然后离开package-lock.json并删除另一个文件,例如yarn.lock

然后执行这些命令。

  1. $ git add。
  2. $ git commit -m“已删除纱线锁定文件”
  3. $ git push heroku master

答案 28 :(得分:0)

在我的情况下清除buildpack工作 heroku buildpacks:clear

答案 29 :(得分:0)

简单的解决方案是确保你有一个名为&#34; Gemfile&#34;的文件。有资本&#34; G&#34;在你的app文件夹中! :)完全糟透了这不是文档,但整个上午试图弄明白。

答案 30 :(得分:0)

我收到此错误是因为我在我的requirements.txt文件中添加了一行错误:

simplejson=2.6.2

只有一个=,应该有两个:

simplejson==2.6.2

纠正此问题修复了错误。

答案 31 :(得分:-1)

当您有一些尚未添加并提交到git的文件时,就会出现此问题。

inputLabelProp

答案 32 :(得分:-1)

对于我来说,删除package-lock.json可以解决我的问题,

  1. 删除
  2. 提交更改
  3. 再次按下

原来Heroku只接受一个package.json文件:p

相关问题