git出现 fatal: Path 'xxxxxxx/*' is in submodule '/xxxxxxx' 问题解决方法

 

开发过程中git仓库中增加了一个文件夹和下面对应的文件

使用正常流程  git add,git commit,git push 后没有发现什么异常

直到有一天我突然发现服务器仓库里有这个文件夹但是文件夹下是空的

使用 git status查看提示

[demo@xxx]$ git status
# On branch master
nothing to commit, working directory clean

进入到改文件夹下直接强行add这些文件

[demo@xxx]$ git add *
fatal: Path 'xxxxxxx/*' is in submodule '/xxxxxxx'

看起来git仓库之前是由于什么原因吧这个文件夹当做一个submodule来处理了(但其实这个文件夹下并没有.git子文件夹)

采用如下方法问题得到解决:

[demo@xxx]$ git rm -rf  --cached /xxxxxxx
fatal: Path 'xxxxxxx/*' is in submodule '/xxxxxxx'

[demo@xxx]$ git status
# On branch master
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# deleted: xxxxxxx
#
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
#  xxxxxxx/

仓库已经不在吧该文件夹作为submodule处理,而是当做普通文件夹对待了

后面再使用正常的 git add,git commit,git push 即可

posted @ 2023-08-17 14:37  蛮哥哥  阅读(96)  评论(0编辑  收藏  举报