代码推到英雄不工作 [英] code push to heroku not working
问题描述
我想在gihub上的heroku上推一下代码
我使用以下命令
git push heroku mybranch:master
错误是
https://github.com/user/lyricle-new.git
! [拒绝] lyricle-frt-backend - >主(非快进)
错误:无法推一些参考https://github.com/user/app.git
提示:更新被拒绝,因为推送的分支提示是在其远程
提示:对方后面。检查这个分支,并合并远程更改
hint:(例如git pull),再次按下。
提示:有关详细信息,请参阅git push --help中的关于快进的注意事项。
使用命令 git pull
提示响应是已经是最新的。
可能是这个错误背后的原因?这是推动英雄的正确方法
通过做 git push heroku mybranch:master
,您正在告诉git,将本地 mybranch
分支,并将其与远程 master
分支(远程存储在您的英雄回购)。
您会收到错误,因为 master
在$ code> mybranch 之前提交。
考虑这个例子:
master:-------- b --------- m ---------
mybranch:....... .\ -c - c - / ...........
在某些时候,你分支( b )主进入mybranch,提交( c )一些代码到分支,并合并( m )它回到主。 p>
现在考虑这个例子:
master:--c ----- b --- c ---- -m --- c--
mybranch:........ \ -c - c --- / .......
几乎一样cenario,但是当您提交代码到 mybranch
时,有人通过提交其他代码更新了 master
。如果要将 mybranch
并入 master
,则可能会导致您的代码与新的代码之间的冲突 master
,因此Git拒绝进行合并。首先,您必须使用新版本的 master
更新本地分支,然后只有Git才能推送。
简而言之
- git pull heroku master:mybranch
- 解决潜在的冲突
- 提交修改的文件
- git push heroku mybranch:master
现在关于Heroku,你应该总是推送这样的代码: git推送英雄主人
(考虑到你在本地的主人
分支)。你应该做些什么来避免像 git push heroku mybranch:master
这样的事情,当你完成分支工作后,总是将你的修改合并到 master
然后(在验证一切正常之后)将主人推送到heroku。
看到这个资源,一个简单的git工作流似乎是你正在寻找: https://www.atlassian.com/git/workflows# !工作流特征分支
所有内容最终都集中在master中,然后您可以定期将主人推送到heroku(理想情况下,您将为每个版本推一次您的应用程式)
I want to push code on heroku that is on gihub
I used the following command
git push heroku mybranch:master
The error is
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.
Used the command git pull
as mentioned in hint the response was Already up-to-date.
What could be the reasons behind this error? and is this the correct way to push on heroku
By doing git push heroku mybranch:master
, you are telling git to take your local mybranch
branch and merge it with the remote master
branch (remotely stored on your heroku repo).
You get an error because master
is ahead of mybranch
in terms of commits.
Consider this example:
master: --------b---------m---------
mybranch:........\-c--c--/...........
At some point, you branch (b) master into mybranch, commit (c) some code to the branch, and merge (m) it back to master.
Now consider this example:
master: --c-----b---c-----m---c--
mybranch:........\-c--c---/.......
It is pretty much the same scenario but while you were committing code to mybranch
, someone updated master
by committing some other code. If you were to merge back mybranch
into master
, you would risk causing conflicts between your code and the new code contained in master
, thus Git refuses to do the merge. First, you have to update your local branch with the new version of master
and then only Git will allow you to push.
In short:
- git pull heroku master:mybranch
- resolve potential conflicts
- commit modified files
- git push heroku mybranch:master
Now about Heroku, you are supposed to always push code like this: git push heroku master
(considering you are on the master
branch locally). What you should do to avoid things like git push heroku mybranch:master
is, when you finish working on a branch, always merge your changes to master
and then (after verifying that everything is working) push master to heroku.
See this resource for a simple git workflow that seem to be what you are looking for: https://www.atlassian.com/git/workflows#!workflow-feature-branch
Everything is centralized in master eventually, and you can then regularly push master to heroku (ideally you would push once for every version of your app)
这篇关于代码推到英雄不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!