这是场景:
1)我的项目合作伙伴和我正在一起使用github作为我们的代码仓库来开发Ruby on Rails应用程序。
2)该应用程序在她的github帐户下,并且她已将我添加为协作者
3)她部署到Heroku,并在那里也添加了我作为合作者
4)我从现有应用程序目录中使用以下命令,目的是将现有Heroku远程应用程序添加为现有本地应用程序的远程服务器。正如我之前提到的,我现有的本地应用程序已经有一个远程github。
git remote add heroku [email protected]:codefellow.git
5)我进行了一些更改并将其推送到github,所有内容都是最新的
6)然后我尝试使用以下命令推送到heroku
git push heroku master
7)这给了我一个错误,说我的分支的尖端在后面,如下所示,但是当我尝试从github上拉时,它说我是最新的,如下所示
➜ code-fellows-alumni git:(master) git push heroku master
To [email protected]:codefellow.git
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to '[email protected]:codefellow.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Merge the remote changes (e.g. 'git pull')
hint: before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
➜ code-fellows-alumni git:(master) git pull
Already up-to-date.
有人知道这是怎么回事吗?如果我与Github保持最新,我的本地分支怎么可能与Heroku不同步?我的项目合作伙伴是否有可能将更改推送到Heroku而不先将其推送到Github?我检查了一下,她没有这个应用程序的分支。我目前无法与她取得联系,无法确定她可能会做些什么-我什至不确定如果尚未将更改推送到Heroku,是否可以让她将更改推送到Heroku。任何见解将不胜感激。我不想从Heroku克隆该应用程序,因为我已经将其与Github进行了本地同步。我想使用Github作为代码存储库,但我不愿意从Heroku的克隆开始。我已经看过有关Heroku的文档:https://devcenter.heroku.com/articles/git。它只是说要克隆,但出于上述原因,我不想这样做。我按照此问题的答案中给出的指示进行操作(如何将文件夹与现有的Heroku应用程序链接),以解决这一问题,但是似乎缺少了一块,否则我的项目合作伙伴做了一些不寻常的事情。在此先感谢您可能有任何有益的想法。
您看到的消息意味着您对本地副本中没有的应用程序进行了更改。当您推送它时,它被拒绝了,因为Heroku远程比您更遥远,因此您认为您的伙伴已将其推送到Heroku而没有推送到Github上是正确的-这是常见的情况,因为在部署到Heroku时是从本地存储库进行部署与传统的Capistrano部署不同,传统的Capistrano部署通常会从Github部署代码。
团队合作需要您自己的工作方法,以防止这种情况的发生,但是如果您需要立即开始工作,则可以
git push heroku master -f
。这将迫使您进行更改,并将覆盖您代码中的当前内容git pull heroku master
将所做的更改从Heroku中提取到您的本地存储库中,然后应git push heroku master
在有更改时执行a操作。本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句