Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/61.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 代码推送到heroku不工作_Ruby On Rails_Ruby On Rails 3_Git_Heroku_Deployment - Fatal编程技术网

Ruby on rails 代码推送到heroku不工作

Ruby on rails 代码推送到heroku不工作,ruby-on-rails,ruby-on-rails-3,git,heroku,deployment,Ruby On Rails,Ruby On Rails 3,Git,Heroku,Deployment,我想把代码推到gihub上的heroku上 我使用了以下命令 git push heroku mybranch:master 错误是 To https://github.com/user/lyricle-new.git ! [rejected] lyricle-frt-backend -> master (non-fast-forward) error: failed to push some refs to 'https://github.com/user/app.gi

我想把代码推到gihub上的heroku上

我使用了以下命令

git push heroku mybranch:master
错误是

To https://github.com/user/lyricle-new.git
 ! [rejected]        lyricle-frt-backend -> master (non-fast-forward)
error: failed to push some refs to 'https://github.com/user/app.git'
hint: Updates were rejected because a pushed branch tip is behind its remote
hint: counterpart. Check out this branch and merge the remote changes
hint: (e.g. 'git pull') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
使用提示中提到的命令
git pull
,响应
已经是最新的。


这一错误背后的原因可能是什么?这是推送heroku的正确方法吗?根据提示,您似乎没有将最新的更改推送到远程存储库。如果您已经拉送并再次推送,可能您已经删除了本地存储库中未在远程存储库中删除的文件。请尝试执行git add--all,然后提交并推送变化

通过执行git push heroku mybranch:master,您告诉git将您的本地
mybranch
分支与远程
master
分支合并(远程存储在heroku repo上)。
出现错误是因为
master
在提交方面领先于
mybranch

考虑这个例子:
master:-----------b------m------
mybranch:…..-c--c--/..

在某个时刻,您将(b)master分支到mybranch,将(c)一些代码提交到分支,然后将(m)它合并回master

现在考虑这个例子:
master:--c--b--c--m--c--
mybranch:…..-c--c---/….

这几乎是相同的场景,但当您向
mybranch
提交代码时,有人通过提交其他代码更新了
master
。如果要将
mybranch
合并回
master
,可能会导致代码与
master
中包含的新代码发生冲突,因此Git拒绝进行合并。首先,您必须使用新版本的
master
更新您的本地分支,然后只有Git允许您推送

简而言之:
-
git-pull-heroku-master:mybranch

-解决潜在冲突
-提交修改过的文件
-
git-push-heroku-mybranch:master


现在关于Heroku,您应该总是像这样推送代码:
git推送Heroku master
(考虑到您在本地的
master
分支上)。要避免类似于
git-push-heroku-mybranch:master
这样的事情,您应该做的是,当您完成对分支的操作时,总是将您的更改合并到
master
,然后(在验证一切正常后)将master推送到heroku

请参阅此参考资料,了解一个简单的git工作流,它似乎就是您所要寻找的:


所有内容最终都集中在master中,然后您可以定期将master推送到heroku(理想情况下,您可以为每个版本的应用程序推送一次)

如果您像我一样有两个heroku应用程序(用于制作和登台),在尝试执行
git-push-staging-staging:master
之前,请确保本地
staging
分支与
master
分支是最新的