gpt4 book ai didi

git - 在 `git filter-branch` : Updates were rejected because the tip of your current branch is behind 之后无法推送到 Heroku

转载 作者:太空狗 更新时间:2023-10-29 14:27:07 52 4
gpt4 key购买 nike

我昨天清理了我的提交历史,因为有一些不小心被推送的私有(private)信息。清理我的提交后,我强行推送到我的主分支。我的电脑和我的 repo 协议(protocol)中的一切都是一样的。但是,当我尝试推送到 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.

所以我一直在寻找类似的线程并尝试过:

$ git pull origin mastergit pull --rebase origin master

返回:

 * branch            master     -> FETCH_HEAD
Already up-to-date.

我也试过 git fetch 返回相同的响应。它说一切都是最新的,那么为什么我不能推送到 heroku?这是否与我昨天运行的 git filter-branch 有关,我该如何解决?

最佳答案

Git 的设计方式可以防止您覆盖任何已经推送到远程的分支。您的 git filter-branch 是重写分支历史的众多方法之一(您在问题中直接得到了那部分)。

git push 上的 --force 选项允许您更新远程分支,而不管历史上是否存在任何分歧。

请注意,从技术上讲,不能保证您的私有(private)信息会被完全删除。

  1. 它仍然在您的本地存储库中,我们称之为悬挂提交
  2. 它仍然在远程对象上,但不一定被任何分支引用。如果是这种情况,可以安全地假设 future 的克隆或提取不会检索这些对象。如果您可以通过命令行访问 git 服务器,您可能仍想在那里运行 git gc
  3. 如果其他人已经 pull 了您的分支,它就会在其他人的存储库中。您对此无能为力,因此默认情况下您应该认为您的数据已被泄露。

关于git - 在 `git filter-branch` : Updates were rejected because the tip of your current branch is behind 之后无法推送到 Heroku,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32444943/

52 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com