You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

主Git仓库受子目录仓库干扰,执行git status时报错的问题求助

主Git仓库受子目录仓库干扰,执行git status时报错的问题求助

大家好,我最近碰到个Git的棘手问题,想请教下社区的朋友们:

我平时做研究时,习惯把关联的代码仓库克隆到主项目的子目录中,主项目根目录就是我的主Git仓库,所有提交操作都在这个主仓库里完成。但换了新Mac之后,这个主仓库突然没法正常工作了。

我先检查了远程仓库配置,执行命令 git remote -v,得到的结果是正确的远程地址:

origin https://github.com/my_user_id/this_project.git (fetch)
origin https://github.com/my_user_id/this_project.git (push)

接着我确认本地仓库的根路径,执行 git rev-parse --show-toplevel,返回的本地路径也没问题:

~/my_user_id/Documents/my_projects/this_project

可当我执行 git status 查看仓库状态时,却弹出了报错提示:

fatal: '~/my_user_id/Documents/my_projects/this_project/other_subproject/.git' not recognized as a git repository

有没有人遇到过类似的情况?麻烦帮我分析下问题出在哪,该怎么解决,非常感谢!

备注:内容来源于stack exchange,提问作者Joe

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.21 09:39:32