【问题标题】:Restore not committed files in GIT在 GIT 中恢复未提交的文件
【发布时间】:2016-04-27 05:08:47
【问题描述】:

我在提交更改之前推送了我的一个分支,然后签出到另一个分支。然后我做了 git reset 使这个分支类似于 origin。远程分支也已被删除。现在,当我切换回第一个分支时,我看不到那里的文件。这些文件已添加,但未提交。如何恢复文件?

【问题讨论】:

  • stackoverflow.com/q/1108853/4289417。 “git fsck --cache --no-reflogs --lost-found --unreachable HEAD”应该会有所帮助。
  • 这给了我一个无法访问的 blob。现在我能用它做什么?
  • Err 不,您实际上无法检查出来。有关详细信息,请参阅链接,但您可以运行,例如“git show -p --format=raw $blob”等。另请参阅.git/lost-found。
  • 是的。你拯救了我的一天
  • 您应该将其添加为@PavelChernikov 的答案。那是一些严肃的 git 魔法! :)

标签: git commit restore git-commit


【解决方案1】:

运行以下命令以显示无法访问的 git 对象:

git fsck --cache --no-reflogs --lost-found --unreachable HEAD

要将它们放在 .git/lost-found 中,请跳过 --unreachable 标志。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-03-15
    • 2021-03-26
    • 1970-01-01
    • 2015-10-08
    • 2021-04-13
    • 2016-06-23
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多