[英]Can't push to Heroku after a `git filter-branch`: Updates were rejected because the tip of your current branch is behind
I cleaned up my commit history yesterday because there was some private information that had accidentally been pushed. 我昨天清理了我的提交历史,因为有一些私人信息被意外推送。 After cleaning my commits, I force pushed to my master branch. 清理完提交后,我强行推送到我的主分支。 Everything is the same both on my computer and in my repo. 在我的电脑和我的回购中,一切都是一样的。 However, when I try to push to Heroku I get this error: 但是,当我尝试推送到Heroku时,我收到此错误:
Updates were rejected because the tip of your current branch is behind its remote counterpart. Integrate the remote changes (e.g.'git pull ...') before pushing again.
So I have been looking through similar threads and have tried: 所以我一直在寻找类似的线程,并尝试过:
$ git pull origin master
and git pull --rebase origin master
$ git pull origin master
和git pull --rebase origin master
which returns: 返回:
* branch master -> FETCH_HEAD
Already up-to-date.
I have also tried git fetch
which returns the same response. 我也尝试过git fetch
,返回相同的响应。 It says everything is up to date, so why can't I push to heroku? 它说一切都是最新的,为什么我不能推送到heroku? Does this have to do with the git filter-branch
I ran yesterday, and how do I fix it? 这与我昨天运行的git filter-branch
什么关系,我该如何解决?
Git is designed in such a way that it will prevent you from overwriting any branches that have already been pushed to a remote. Git的设计方式可以防止你覆盖任何已被推送到遥控器的分支。 Your git filter-branch
is one of many ways of rewriting a branch's history (you got that part straight in your question). 你的git filter-branch
是重写分支历史的众多方法之一(你在问题中直接得到了这一部分)。
The --force
option on git push
lets you update a remote branch regardless of any divergences in history. git push
上的--force
选项允许您更新远程分支,而不管历史记录中是否存在任何差异。
Note that technically your private information is not guaranteed to be completely deleted. 请注意,从技术上讲,您的私人信息不能保证完全删除。
dangling commits
它仍然在你的本地存储库中,我们称之为dangling commits
git gc
over there. 如果您对git服务器有命令行访问权限,那么您可能仍希望在那里运行git gc
。 Well I haven't seen this before, but I figured I would give it a go: 好吧,我以前没见过这个,但我想我会试一试:
git push --force heroku master
and what do ya know? 你知道什么? It worked :) 有效 :)
For this works. 对于这项工作。
heroku plugins:install heroku-repo
heroku repo:reset -a <yourappname>
git push heroku master
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.