简体   繁体   English

在'git filter-branch`之后无法推送到Heroku:更新被拒绝,因为当前分支的提示落后了

[英]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 mastergit 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. 请注意,从技术上讲,您的私人信息不能保证完全删除。

  1. It's still in your local repository, in what we call dangling commits 它仍然在你的本地存储库中,我们称之为dangling commits
  2. It's still on the objects on the remote, but not necessarily referenced by any branch. 它仍然在遥控器上的对象上,但不一定由任何分支引用。 If that's the case, it's safe to assume no future clones or fetches will retrieve those objects. 如果是这种情况,可以安全地假设将来没有克隆或提取将检索这些对象。 If you have command-line access to the git server you might still want to run git gc over there. 如果您对git服务器有命令行访问权限,那么您可能仍希望在那里运行git gc
  3. It's on anyone else's repository if they have already pulled your branch. 如果他们已经拉你的分支,它就在其他人的存储库中。 There's nothing you can do about this, so you should by default consider your data to be compromised. 关于此,您无能为力,因此默认情况下您应该考虑将数据泄露。

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.

相关问题 更新被拒绝,因为您当前分支的提示落后 - 但为什么? - Updates were rejected because the tip of your current branch is behind - but why? 更新被拒绝,因为您当前分支的尖端在后面...不正确 - Updates were rejected, because the tip of your current branch is behind… Not true Git 更新被拒绝,因为您当前分支(主)的尖端在后面但是分支是最新的? - Git Updates were rejected because the tip of your current branch (main) is behind BUT branch is up to date? 源树推送:提示:更新被拒绝,因为当前分支的尖端落后 - Source Tree Push : hint: Updates were rejected because the tip of your current branch is behind Git 错误更新被拒绝,因为您当前分支的提示落后 - Git error Updates were rejected because the tip of your current branch is behind git:“更新被拒绝,因为您当前分支的尖端落后..”但是如何查看差异? - git: "Updates were rejected because the tip of your current branch is behind.." but how to see differences? 如何解决 git 错误:“更新被拒绝,因为您当前分支的提示落后了” - How to resolve git error: "Updates were rejected because the tip of your current branch is behind" 如何解决“由于当前分支的尖端落后而导致更新被拒绝”? - How can I solve “Updates were rejected because the tip of your current branch is behind”? 如何解决git错误:重命名远程分支时“更新被拒绝,因为当前分支的提示落后” - How to resolve git error: “Updates were rejected because the tip of your current branch is behind” when renaming a remote branch 收到错误“更新被拒绝,因为您当前分支的提示落后了” - Getting error “Updates were rejected because the tip of your current branch is behind”
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM