我有一个问题推到另一个heroku遥控器.
为了检查自己,我将整个项目目录重命名为_backup,然后:
git clone account/repo_name
git remote add repo2 git@heroku.com:repo2.git
git push repo2 branch_abc:master
Run Code Online (Sandbox Code Playgroud)
但我还是得到了
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.
Run Code Online (Sandbox Code Playgroud)
我已经尝试了几个SO问题和答案,但没有为我工作,仍然得到错误无论如何.
uda*_*day 36
如果您不关心当前处于repo2中的内容并确信完全覆盖它就可以了,那么您可以使用:
$ git push -f git@heroku.com:<heroku repo name>.git
Run Code Online (Sandbox Code Playgroud)
请记住,如果自上次从回购中push -f 删除后发布的其他开发人员的更改可能会消失 ...所以请始终谨慎使用多开发人员团队!
在这种情况下,heroku总是在下游,而github是代码管理和维护的地方,因此这push -f对heroku来说是一个更安全的选择.
我一直是使用git pull --rebase然后git push origin master的忠实粉丝.我工作过的几个地方,因为很多地方不允许推-f(特别是那些使用bitbucket的地方).
git pull?--rebase
git push origin master
Run Code Online (Sandbox Code Playgroud)
rebase将在已经更改到远程(在线网站)之后应用您的更改.这个视频完全解决了你的确切问题并使用git pull解决了它--rebase https://youtu.be/IhkvMPE9Jxs?t=10m36s