如何“解决致命问题:不是git存储库”? [英] How to "resolve fatal: Not a git repository"?

查看:99
本文介绍了如何“解决致命问题:不是git存储库”?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图从项目中删除一个子模块



试过 rm -rf .git / modules / submodulePath



之后,我遇到了问题



致命:不是git存储库

解决方案

这两个文件包含绝对子模块路径:

  {submodule} / .git 
.git / modules / {submodule} / config



所以,如果你移动回购,这两个文件中的绝对路径是无效的,并导致'不是git仓库'错误。只需手动修复这些文件即可。



更新:

.gitmodules文件中的相关部分。你可以使用下面的命令:

  git config -f .gitmodules --remove-sectionsubmodule.submodule_name

2)。阶段.gitmodules更改

  git add .gitmodules 

3.)从.git中删除相关部分/配置。您可以使用以下命令:

  git submodule deinit -fsubmodule_name

4.)移除gitlink(无斜线):

  git rm --cached path_to_submodule 

5)清理.git /模块: p>

  rm -rf .git / modules / path_to_submodule 

$ b)提交:

  git commit -m已删除的子模块<名称>  

7.)删除现在未跟踪的子模块文件

  rm -rf path_to_submodule 


I was trying to remove one sub-module from the project

Tried rm -rf .git/modules/submodulePath

After that I am having the issue

fatal: Not a git repository

解决方案

These two files contains absolute submodule path:

{submodule}/.git
.git/modules/{submodule}/config

So, if you moved the repo, the absolute path in these two files are not valid, and cause the 'not a git repository' error. Just fix these files manually.

Update:

1.) Delete the relevant section from the .gitmodules file. You can use below command:

git config -f .gitmodules --remove-section "submodule.submodule_name"

2.) Stage the .gitmodules changes

git add .gitmodules

3.) Delete the relevant section from .git/config. You can use below command:

git submodule deinit -f "submodule_name"

4.) Remove the gitlink (no trailing slash):

git rm --cached path_to_submodule

5.) Cleanup the .git/modules:

rm -rf .git/modules/path_to_submodule

6.) Commit:

git commit -m "Removed submodule <name>"

7.) Delete the now untracked submodule files

rm -rf path_to_submodule

这篇关于如何“解决致命问题:不是git存储库”?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆