Dan*_*Dan 5 git github visual-studio-code
我刚刚回到一个我已经使用 Git 大约 6 个月的项目,看到了这个:
$ cd /d/DEVELOP/BlenderAe # My repo root
$ git status
fatal: not a git repository (or any of the parent directories): .git
Run Code Online (Sandbox Code Playgroud)
这绝对是正确的路径,为什么 git 无法识别我的本地克隆?
我最后的行动是:
git文件夹内容如下:
$ cd /d/DEVELOP/BlenderAe # My repo root
$ ls .git
ORIG_HEAD objects/ refs/
Run Code Online (Sandbox Code Playgroud)
我确实有当前的代码(在 git 之外对其进行了备份)。我该如何重新连接?还有我的 github 远程吗?
修复后ORIG_HEAD我看到:
$ git status
Not currently on any branch.
Changes to be committed:
(use "git restore --staged <file>..." to unstage)
deleted: (old_file1).py
...all the older files that were previously renamed/deleted are listed here for deletion.
Untracked files:
(use "git add <file>..." to include in what will be committed)
Current_file1.py
...all the current files are listed here as untracked.
Run Code Online (Sandbox Code Playgroud)
.git/HEAD失踪了\n\n\n
ls .git节目ORIG_HEAD objects/ refs/
不完整,比较一下:
\n$ git init\n$ tree .git\n.git\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 HEAD\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 config\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 description\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 hooks\n\xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 applypatch-msg.sample\n\xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 commit-msg.sample\n\xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 fsmonitor-watchman.sample\n\xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 post-update.sample\n\xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 pre-applypatch.sample\n\xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 pre-commit.sample\n\xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 pre-merge-commit.sample\n\xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 pre-push.sample\n\xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 pre-rebase.sample\n\xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 pre-receive.sample\n\xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 prepare-commit-msg.sample\n\xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 update.sample\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 info\n\xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 exclude\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 objects\n\xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 info\n\xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 pack\n\xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 refs\n \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 heads\n \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 tags\n\n8 directories, 16 files\nRun Code Online (Sandbox Code Playgroud)\n缺少 git 正在查找以检测 git 存储库的文件是HEAD。
$ mv .git/HEAD .git/ORIG_HEAD\n$ git status\nfatal: not a git repository (or any of the parent directories): .git\nRun Code Online (Sandbox Code Playgroud)\nORIG_HEAD的存在ORIG_HEAD表明 git 正在做一些破坏性的事情,以便从中恢复(或者可能不会看到下一个问题):
$ mv .git/ORIG_HEAD .git/HEAD \n$ git status\nOn branch main\n\nNo commits yet\n\nnothing to commit (create/copy files and use "git add" to track)\nRun Code Online (Sandbox Code Playgroud)\n如果HEAD文件丢失并且不存在ORIG_HEAD文件 - 如果这是唯一的问题,那么仍然可以恢复。该HEAD文件是纯文本,指示当前签出哪个分支:
\n\n通常 HEAD 文件是对当前所在分支的符号引用\xe2\x80\x99
\n
例子:
\n$ cat .git/HEAD\nref: refs/heads/main\nRun Code Online (Sandbox Code Playgroud)\n如果 git 存储库的其他内容(和文件夹内容)仍然存在,则.git/HEAD使用该内容创建(替换为任何有效的分支名称)将允许在 git 存储库上进行操作。main.git/objects.git/refs
| 归档时间: |
|
| 查看次数: |
3555 次 |
| 最近记录: |