推送到github时出错-更新被拒绝,因为推送的分支提示在其远程后面 [英] Getting an error pushing to github - Updates were rejected because a pushed branch tip is behind its remote

查看:429
本文介绍了推送到github时出错-更新被拒绝,因为推送的分支提示在其远程后面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在推到另一个heroku遥控器时遇到问题.

I am having a problem pushing to a different heroku remote.

要检查自己,我将整个项目目录重命名为_backup,然后:

To check myself I renamed my entire project directory to _backup and then:

git clone account/repo_name

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

git push repo2 branch_abc:master

但是我仍然得到

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.

我已经尝试了几个SO问题和答案,但对我没有用,无论如何仍然会出现错误.

I have tried several SO questions and answers but not worked for me, still getting the error regardless.

推荐答案

如果您不关心repo2中的当前内容,并且有信心完全覆盖它就可以了,那么您可以使用:

$ git push -f git@heroku.com:<heroku repo name>.git

请记住,虽然push -f 可以清除其他开发人员的更改(如果这些更改是自您上次从存储库中撤出以来发布的),所以在多开发人员团队上要格外小心!
在这种情况下,heroku始终位于下游,而github是管理和维护代码的位置,因此这使heroku上的push -f成为了更安全的选择.

Remember though that push -f can wipe out other developers changes if they were posted since you last pulled from the repo... so always use with extreme caution on multi-developer teams!
In this case heroku is always downstream and github is where the code is managed and maintained so this makes push -f on heroku a safer option that it would otherwise be.

这篇关于推送到github时出错-更新被拒绝,因为推送的分支提示在其远程后面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆