【问题标题】:Undelete specific empty commits after rewriting history with prune-empty使用 prune-empty 重写历史记录后取消删除特定的空提交
【发布时间】:2018-01-29 00:05:55
【问题描述】:

我用 filter-branch & --prune-empty 重写了 git 历史。现在我需要恢复一些带有特定消息的提交。我可以这样做吗?我不运行 git reflog 或 git gc

【问题讨论】:

  • 我认为如果你能找出你核对的提交的 SHA-1 哈希值,你可以通过多种方式将它们带回你的分支。这些提交可能仍在 reflog 中。
  • @TimBiegeleisen 是的,我知道他们还在 reflog 中。但我不知道 a) 如何处理所有提交,包括已删除(filter-branch 是否也会处理它们?)以及如何根据特定消息的条件恢复它们。
  • 我也可以从 repo 备份中获取所需的哈希值并手动恢复它们,但如果可能的话,我想避免这种情况并自动找到这个提交

标签: git git-rewrite-history pruning


【解决方案1】:

您可以使用git logsearch a commit by commit message

作为mentioned heregit log has a --grep-reflog option,它允许您对丢失的提交进行 grep 提交消息。

然后您可以将list the SHA1 only 与--format=format:%H 联系起来。

【讨论】:

    猜你喜欢
    • 2014-05-05
    • 1970-01-01
    • 2013-09-20
    • 2012-04-06
    • 2014-06-24
    • 2023-01-22
    • 1970-01-01
    • 2012-12-14
    • 2014-02-21
    相关资源
    最近更新 更多