【问题标题】:How to retrieve files from git cache?如何从 git 缓存中检索文件?
【发布时间】:2018-11-16 15:46:30
【问题描述】:

我在远程 github 中创建了一个新的 repo,并在初始提交后尝试推送本地文件。由于存储大小限制推送失败。不知何故,本地磁盘中的文件丢失了(ls -alrt 仅列出空目录)。现在这些文件既不能在本地磁盘(包括垃圾)中使用,也不能在远程 git 中使用。但是,它在本地 git 缓存中可用,该缓存会显示在 Git Desktop 中。

请告诉我如何将它们从 Git 缓存中检索到本地磁盘。

详情: Mac OS Sierra - 10.12 ++ Git - 2.19.0 ++ Github 桌面 - 1.5.0

Github Desktop displaying the content from cache(?)

git 日志 -a 提交 d1dd6d3c1ae871ba0ea26ae4d819c9dd2b6d1a8e (HEAD -> master) 作者:A… 日期:2018 年 11 月 14 日星期三 15:34:11 -0700

Revert "intial commit"

This reverts commit 9233a2e0fd96f7837d1cdf198795a9f57d3d7f4b.

提交 052adad2e2f31ed3eced327ae4893a8c0468dce4 作者:A… 日期:2018 年 11 月 14 日星期三 15:34:09 -0700

Revert "initial commit"

This reverts commit 821e08a29a5cb908b187230318ee0b9f352a63cc.

提交 c198ae2456bc9b0805fb35bfd08b962dbcf75173 作者:A… 日期:2018 年 11 月 14 日星期三 15:34:05 -0700

Revert "initial commit"

This reverts commit 1e66da35ab95d3cbe63ed597c8aeb409cb7ad4af.

提交 1393929072b7454387bac46c4a7b81bb69b6f9ca 作者:A… 日期:2018 年 11 月 14 日星期三 15:31:17 -0700

added jmx files

提交 9233a2e0fd96f7837d1cdf198795a9f57d3d7f4b 作者:A… 日期:2018 年 11 月 14 日星期三 15:29:49 -0700

intial commit

提交 821e08a29a5cb908b187230318ee0b9f352a63cc 作者:……..MacBook-Pro.local> 日期:2018 年 11 月 14 日星期三 15:17:56 -0700

initial commit

提交 1e66da35ab95d3cbe63ed597c8aeb409cb7ad4af 作者:……..MacBook-Pro.local> 日期:2018 年 11 月 14 日星期三 15:07:28 -0700

initial commit

1+ 停止 git log -a

$ git 状态

在分支主 未跟踪的文件: (使用“git add ...”来包含将要提交的内容)

xxxx/xxxxx-Release/TestResults/
xxxx/xxxxRelease/
xxxx/xxxx-Release/
xxxx/xxRelease/TestResults/
xxxxxx-Release/TestResults/

没有添加到提交但存在未跟踪的文件(使用“git add”进行跟踪)

【问题讨论】:

  • 我对 Git Desktop 不熟悉。你能提供一个截图来展示你所看到的吗?
  • 什么是 git 缓存?
  • 嗨!从您的终端,git status 的输出会有所帮助
  • 我在 git status 之外添加了 git log -a 的输出

标签: git github


【解决方案1】:

我认为您所指的“缓存”是 git internal 的提交文件系统快照。 (即提交的文件)

如果正确,git reset --hard 1e96da3git clean -f(如果要删除所有未跟踪的文件,则可选)。

如果你想恢复一些丢失的提交,那么git reflog 来获取丢失的提交的SHA-1 哈希值和git reset --hard SHA-1

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-10-28
    • 1970-01-01
    • 2014-05-31
    • 2010-09-09
    • 2011-10-21
    • 2018-03-27
    相关资源
    最近更新 更多