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

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

问题描述



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

  git克隆账户/ repo_name 

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

git push repo2 branch_abc:master

但我仍然收到

 提示:更新被拒绝,因为推送的分支提示位于其远程
提示:对手后面。在再次推送之前,检查此分支并合并远程更改
提示:(例如'git pull')。
提示:有关详细信息,请参阅'git push --help'中的'关于快速转发的注意事项'。

我已经尝试了几个SO问题和答案,但对我无效,无论如何仍然收到错误消息。 / p>

解决方案

如果您不关心repo2中的内容,并且确信完全覆盖就可以了然后你可以使用:

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

请记住, push -f 可以消除其他开发人员更改,因为如果自从您上次从回购中拉出后发布更改...所以请始终谨慎地在多个开发人员团队中使用!

在此情况下,heroku始终是下游而github是代码管理和维护的地方,所以这使得heroku上的 push -f 成为一种更安全的选项。


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

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

But I am still getting

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.

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

解决方案

If you don't care about what's currently in repo2 and are confident that totally overwriting it is ok then you can use:

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

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天全站免登陆