简体   繁体   English

将远程heroku存储库添加到我现有的本地存储库后,无法推送到heroku

[英]Cannot push to heroku after adding a remote heroku repo to my existing local repo

Here is the scenario: 这是场景:

1) My project partner and I were working on a Ruby on Rails app together using github as our code repo. 1)我的项目合作伙伴和我正在一起使用github作为我们的代码仓库来开发Ruby on Rails应用程序。

2) The app is under her github account and she had added me as a collaborator 2)该应用程序在她的github帐户下,并且她已将我添加为协作者

3) She deployed to Heroku and added me as a collaborator there as well 3)她部署到Heroku,并在那里也添加了我作为合作者

4) I used the following command from my existing app directory with the intention of adding the existing Heroku remote app as a remote to my existing local app. 4)我从现有应用程序目录中使用以下命令,目的是将现有Heroku远程应用程序添加为现有本地应用程序的远程服务器。 My existing local app, as I mentioned before, already had a remote github 如前所述,我现有的本地应用程序已经有一个远程github

git remote add heroku git@heroku.com:codefellow.git 

5) I made some changes and pushed them to github and all was up to date 5)我进行了一些更改并将其推送到github,所有内容都是最新的

6) Then I attempted to push to heroku with the following command 6)然后我尝试使用以下命令推送到heroku

git push heroku master

7) This gave me an error saying the tip of my branch was behind, as shown below, but when I tried to pull from github, it said I was up to date, as also shown below 7)这给了我一个错误,说我的分支的尖端在后面,如下所示,但是当我尝试从github拉时,它说我是最新的,如下所示

➜  code-fellows-alumni git:(master) git push heroku master
To git@heroku.com:codefellow.git
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'git@heroku.com: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.

So does anyone know what is going on here? 有人知道这里发生了什么吗? How could my local branch be out of sync with Heroku if I'm up to date with Github? 如果我与Github保持最新,我的本地分支怎么可能与Heroku不同步? Would it have been possible for my project partner to have pushed changes to Heroku without having pushed them to Github first? 我的项目合作伙伴是否有可能将更改推送到Heroku而不先将其推送到Github? I checked and she does not have a fork of the application. 我检查了一下,她没有这个应用程序的分支。 I cannot get in touch with her at the moment to find out for sure what she might have done--I'm not even sure it would allow her to push changes to Heroku if they hadn't been pushed to Github yet. 我目前无法与她取得联系,无法确定她可能会做些什么-我什至不确定如果还没有将更改推送到Github,是否可以允许她将更改推送到Heroku。 Any insights would be much appreciated. 任何见解将不胜感激。 I don't want to clone the app from Heroku necessarily because I already have it locally synced with Github. 我不想从Heroku克隆该应用程序,因为我已经将其与Github进行了本地同步。 I want to use Github as the code repository and I am reluctant to start from a clone from Heroku. 我想使用Github作为代码存储库,但我不愿意从Heroku的克隆开始。 I've already looked at the Heroku documentation on this: https://devcenter.heroku.com/articles/git . 我已经在以下网站上查看了Heroku文档: https : //devcenter.heroku.com/articles/git It just says to do a clone but I don't want to do that for the aforementioned reasons. 它只是说要克隆,但由于上述原因,我不想这样做。 I followed the directions given in the answer to this question ( How to link a folder with an existing Heroku app ) to get this far but it seems like there is a missing piece or else my project partner has done something unusual. 我按照此问题的答案中给出的指示进行操作( 如何将文件夹与现有的Heroku应用程序链接 ),以解决这一问题,但是似乎缺少了一块,否则我的项目合作伙伴做了一些不寻常的事情。 Thanks in advance for any helpful ideas you might have. 在此先感谢您可能有任何有益的想法。

The message you are seeing means that changes have been made to the application that you do not have in your local copy. 您看到的消息意味着您对本地副本中没有的应用程序进行了更改。 When you push it's rejected because the Heroku remote is further ahead than yours, so you're right in thinking that your partner has pushed to Heroku without pushing to Github - it's a common scenario since you deploy from your local repository when you deploy to Heroku, unlike a traditional Capistrano deploy which would deploy the code from Github typically. 当您推送它被拒绝时,是因为Heroku远程比您更遥远,因此您认为您的伙伴已将其推送到Heroku而没有推送到Github上是正确的-这是常见的情况,因为当您部署到Heroku时是从本地存储库部署的与传统的Capistrano部署不同,传统的Capistrano部署通常会从Github部署代码。

It's down to you as a team to come up with ways of working which prevent this from occuring, but if you need to get working right now, you can either 团队合作由您自己来决定可以防止这种情况发生的方法,但是如果您需要立即开始工作,则可以

  • git push heroku master -f . git push heroku master -f This forces your changes and will overwrite what's there presently with your code 这将迫使您进行更改,并将覆盖您代码中的当前内容
  • git pull heroku master to pull the changes from Heroku into your local repo which should then let you do a git push heroku master when you have the changes. git pull heroku master将所做的更改从Heroku中提取到您的本地存储库中,然后,当您进行更改时,应该让您执行git push heroku master

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM