Heroku:如何在“git push -f”之后“git pull”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12415875/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Heroku: how to "git pull" after 'git push -f'
提问by Leahcim
I got this error message (copied below) after trying to push to Heroku. I initially set up a facebook canvas app and selected the hosting on heroku options. It gave me a heroku url, which I added as a remote on the app I was developing on my machine
尝试推送到 Heroku 后,我收到了此错误消息(复制如下)。我最初设置了一个 facebook 画布应用程序并选择了在 heroku 上托管选项。它给了我一个 heroku url,我在我的机器上开发的应用程序上添加了它作为遥控器
heroku git:remote -a desolate-springs-1684
But when I pushed, I got this error
但是当我按下时,我收到了这个错误
error: failed to push some refs to '[email protected]:desolate-springs-1684.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.
localhost:nhl michaelmitchell$
So I did
所以我做了
git push -f heroku master
But now I apparently have to do a 'git pull'. However, what do i put after the 'git pull'? The name of the heroku url? or something else?
但现在我显然必须做一个'git pull'。但是,在“git pull”之后我该放什么?heroku 网址的名称?或者是其他东西?
回答by Simone Carletti
Forcing your git push
was not a good idea because you lost any commit that was done by you or other collaborators you were missing on your working copy.
强制你git push
不是一个好主意,因为你丢失了你或其他合作者所做的任何提交,你在工作副本中丢失了。
Before pushing, you should have either merged or rebased the upstream changes into your local working copy.
在推送之前,您应该将上游更改合并或重新定位到您的本地工作副本中。
To merge the changes locally
在本地合并更改
$ git pull heroku master
$ git push heroku master
To rebase the changes locally
在本地重新设置更改
$ git pull --rebase heroku master
$ git push heroku master
BTW, now that you have pushed your changes, you actually don't need to do anything else. The remote repository already contains all your changes.
顺便说一句,既然你已经推送了你的更改,你实际上不需要做任何其他事情。远程存储库已包含您的所有更改。
If for whatever reason the $ git status
command is returning outdated references, simply run
如果由于某种原因该$ git status
命令返回过时的引用,只需运行
$ git pull heroku
to fetch all the remote changes. Please note that unless you specify a target branch (or you have the tracking branch enabled), git pull
will simply download (and not merge) the upstream changes.
获取所有远程更改。请注意,除非您指定目标分支(或者您启用了跟踪分支),git pull
否则只会下载(而不是合并)上游更改。
Also note that Heroku should not be considered a git hosting. It means that it's extremely uncommon to perform a git pull
from Heroku. Instead, you should use a git hosting (such as GitHub or BitBucket) to store your repository and only perform push to Heroku to deploy the application.
另请注意,不应将 Heroku 视为 git 托管。这意味着git pull
从 Heroku执行 a 非常罕见。相反,您应该使用 git 托管(例如 GitHub 或 BitBucket)来存储您的存储库,并且只执行推送到 Heroku 以部署应用程序。
回答by Joey Hoang
That error basically means that there is code in the repo that is newer than the code you're trying to push to it.
该错误基本上意味着存储库中的代码比您尝试推送的代码更新。
you have to do a pull and update your own working repository then push again, or just force a push
您必须执行拉取并更新您自己的工作存储库,然后再次推送,或者只是强制推送
git pull heroku master
As a side note, if you aren't familiar with all the git commands, I would recommend you use a GUI as it may make the whole process a lot less overwhelming.
附带说明一下,如果您不熟悉所有 git 命令,我建议您使用 GUI,因为它可以使整个过程不那么令人不知所措。
There are plenty of great clients here: http://git-scm.com/downloads/guis
这里有很多很棒的客户:http: //git-scm.com/downloads/guis