Git随机重置为初始提交

时间:2017-02-07 18:02:28

标签: git

过去几天我已经执行了4次我执行了一个看似无害的git命令(git push或git diff),然后git突然似乎指向了项目的初始提交。该存储库已有10年以上的历史,有数十万次提交。

$ git status
=> On branch my-current-branch-name

Initial commit

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

new file:   .Vagrantfile.example
new file:   .floo
new file:   .flooignore
new file:   .gitignore
new file:   .gitmodules
new file:   .rubocop.yml
... thousands of more files (all new to git) ...

$ git stash list
=> 
$ git tag
=> 
$ git branch
=> * my-current-branch-name
$ git checkout origin/master
=> error: pathspec 'origin/master' did not match any file(s) known to git.

所以我一直在git reset --soft运行同一个分支上最近的SHA,这至少让我回到了我在那个分支上的位置。然后我必须获取存储库并重新签出分支。

我能想到的唯一可能与这个问题有关的是几天前,我得到了:

error: The last gc run reported the following. Please correct the root cause and remove .git/gc.log.
Automatic cleanup will not be performed until the file is removed.
warning: There are too many unreachable loose objects; run 'git prune' to remove them.

所以我运行了git prunerm .git/gc.log。第二天是我第一次遇到初始提交问题。我注意到.git/gc.log尚未重新创建,但.git/gc.log.lock仍然存在。

对于下次发生这种情况我可能会尝试的任何建议?

0 个答案:

没有答案