首页 > 解决方案 > Git文件夹被损坏

问题描述

我克隆了一个 Git 存储库到我的磁盘,它是一个分支

git clone -b branchname git-remote-repo.path.git branchname

一切正常,我可以提交更改并推送到远程仓库。

我使用 VS Code 并且没有 git 支持,我从命令行使用 git。

然后,有时,我不知道是什么原因造成的,我的 .git 文件夹损坏了,当我在文件夹中运行 git 命令时出现错误,例如 git status - 我得到了

fatal: Not a git repository (or any of the parent directories): .git

什么会导致这种情况,例如更改 VS Code 中的工作文件夹?

.git 文件夹仍然存在,但日志或对象等文件夹已被删除。

更多信息:

几个小时后:-) 现在我再次拥有它,我承诺,我推送到远程仓库,一切都很好。我使用 VS Code 对其进行了开发,不再使用 github 扩展,然后:

C:\Projekte\Blender\Addons\fast-carve-2-8>git commit -a
[fast-carve-2-8 ec4e43d] sharpness 60 degree for bevel
 1 file changed, 1 insertion(+), 1 deletion(-)

C:\Projekte\Blender\Addons\fast-carve-2-8>git push origin fast-carve-2-8
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Delta compression using up to 8 threads
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 330 bytes | 330.00 KiB/s, done.
Total 3 (delta 2), reused 0 (delta 0)
remote: Resolving deltas: 100% (2/2), completed with 2 local objects.
To https://github.com/jayanam/fast-carve.git
   2c729eb..ec4e43d  fast-carve-2-8 -> fast-carve-2-8

C:\Projekte\Blender\Addons\fast-carve-2-8>git status
fatal: not a git repository (or any of the parent directories): .git

标签: git

解决方案


推荐阅读