3

Github for Windows just bombed when I tried making a commit and now git (command line) is telling me every file is new. I've still got a .get folder which is 53mb in size. I'd made about 60 to 100 commits previous to this.

How can I recover my working copy without losing any history or changes?

Git status says:

On branch master

Initial commit

Changes to be committed:
(use "git rm --cached ..." to unstage)

new file: .gitattributes
new file: .gitignore
... (1620 more files)

Changes not staged for commit:
(use "git add ..." to update what will be committed)
(use "git checkout -- ..." to discard changes in working directory)

modified: Src/Foo/Bar/Index.cshtml

Untracked files:
(use "git add ..." to include in what will be committed)

The Posh Git command prompt looks like this

C:\Projects\Foo [master +1623 ~0 -0 | +0 ~1 -0]>

The output from git log is as follows

C:\Projects\Foo [master +1623 ~0 -0 | +1 ~1 -0 !]> git log
fatal: bad default revision 'HEAD'

UPDATE

I just ran "Verify Database" from the Git GUI and it came back with the following:

dangling tree 4b825dc642cb6eb9a060e54bf8d69288fbee4904 dangling commit 30855e0deee8600f10733e6760db54fee2570a38 dangling commit cd8bc69ad56ca5c4d51d0d5028525698158cf3ec dangling commit c934f9823d907cd69c5e08a0159b9de4dfe3da35 dangling commit f958caca247978db978b70460276b5da7582bb06 notice: HEAD points to an unborn branch (master) notice: No default references

4

2 回答 2

2

好的,首先,我复制了我的工作副本,所以我总是有一个后备位置。接下来我跑了git fsck,它给出了以下输出。

> dangling tree 4b825dc642cb6eb9a060e54bf8d69288fbee4904 dangling commit
> 30855e0deee8600f10733e6760db54fee2570a38 dangling commit
> cd8bc69ad56ca5c4d51d0d5028525698158cf3ec dangling commit
> c934f9823d907cd69c5e08a0159b9de4dfe3da35 dangling commit
> f958caca247978db978b70460276b5da7582bb06 notice: HEAD points to an
> unborn branch (master) notice: No default references

从这里,我用

git checkout <some-hash>

处理上面悬空提交的哈希值。事实证明,最后一个悬空提交是我最近的提交,所以git checkout c934f9823d907cd69c5e08a0159b9de4dfe3da35让我回到崩溃前的工作副本。

从这里开始git checkout -b master,我在这次提交中重新创建了我的主分支。git status现在显示了一项更改,这是我尝试进行的提交。承诺让我回到正轨。

于 2012-10-22T08:19:38.063 回答
1

首先:不要惊慌。备份您的项目,包括您的工作文件夹。嗯...实际上,做两个:)

我还有一个 .git 文件夹,大小为 53mb。

Git 是一个非常有弹性的工具。对对象数据库的分析可以“重建”您的历史。

此外,GHfW 记录了与 repo 的大部分交互。长话短说,GHfW 团队很有可能会帮助您挽救您的回购协议。

正如公告博客文章所述

我们确保阅读 Twitter 上的每一个提及。如果您发现错误,请将其提交至 support@github.com。每封电子邮件都由真人阅读。

给他们发邮件。就像现在一样。

于 2012-10-21T19:36:03.157 回答