首页 > 其他分享 >git: 报错: no submodule mapping found in .gitmodules for path/位于未检出的子模组

git: 报错: no submodule mapping found in .gitmodules for path/位于未检出的子模组

时间:2024-09-25 19:25:04浏览次数:1  
标签:laravel gitmodules submodule vendor web api git 报错 ui

一,问题的现象:

1,安装laravel/ui这个第三方库后,它的文件不出现在未跟踪文件中,如下:

liuhongdi@lhdpc:/web/api/vendor/laravel/ui$ git ls-files 
./
liuhongdi@lhdpc:/web/api/vendor/laravel/ui$ git ls-files ./
./
liuhongdi@lhdpc:/web/api/vendor/laravel/ui$ ls
auth-backend  composer.json  LICENSE.md  README.md  src  stubs  tests

2,手动把文件添加到git时,报错:

liuhongdi@lhdpc:/web/api/vendor/laravel/ui$ git add composer.json 
fatal: 位于未检出的子模组 'vendor/laravel/ui'

3,查看相应的文件的命令:

[lhdpc@web api]$ git ls-files --stage | grep 160000
160000 c75396f63268c95b053c8e4814eb70e0875e9628 0       vendor/laravel/ui

二,解决办法:

git rm --cache 需要删除的目录

liuhongdi@lhdpc:/web/api$ git rm --cache vendor/laravel/ui
rm 'vendor/laravel/ui'

 查看效果:

liuhongdi@lhdpc:/web/api$ git status
位于分支 devel
要提交的变更:
  (使用 "git restore --staged <文件>..." 以取消暂存)
        删除:     vendor/laravel/ui

尚未暂存以备提交的变更:
  (使用 "git add <文件>..." 更新要提交的内容)
  (使用 "git restore <文件>..." 丢弃工作区的改动)
        修改:     composer.lock
        修改:     vendor/composer/autoload_classmap.php
        修改:     vendor/composer/autoload_static.php
        修改:     vendor/composer/installed.json
        修改:     vendor/composer/installed.php

未跟踪的文件:
  (使用 "git add <文件>..." 以包含要提交的内容)
        vendor/laravel/ui/

 三,执行git submodule有相同的报错:

可以用相同的办法处理

[lhd@web api]$ git submodule
fatal: no submodule mapping found in .gitmodules for path 'vendor/laravel/ui'

四,问题发生的原因:

应该是git仓库之前由于某些原因,把这个文件夹当做一个submodule来处理了
有时是这个文件夹下无意中加进了一个.git文件夹,导致发生了这种情况

 

标签:laravel,gitmodules,submodule,vendor,web,api,git,报错,ui
From: https://www.cnblogs.com/architectforest/p/18431999

相关文章