如果我意外地创建了包含子模块(sub-repo)的repo,如何修复git-repo?

如果我意外地创建了包含子模块(sub-repo)的repo,如何修复git-repo?,git,create-react-app,git-submodules,Git,Create React App,Git Submodules,如果我这样做: mkdir TryReactHooks cd TryReactHooks npx create-react-app my-app git init git remote add origin git@gitlab.com:username/tryreacthooks.git # optional git add . git commit -am "Initial Commit" git push -u origin master 出于某种原因,该回购协议似乎没有跟踪my a

如果我这样做:

mkdir TryReactHooks
cd TryReactHooks
npx create-react-app my-app
git init 
git remote add origin git@gitlab.com:username/tryreacthooks.git  # optional
git add .
git commit -am "Initial Commit"
git push -u origin master
出于某种原因,该回购协议似乎没有跟踪
my app
文件夹中的任何文件。这可能是因为
myapp
本身就是回购协议(因为
createreact app
做到了)。如果我这样做

mv my-app/.git my-app/.git-tmp
因此,
my app
不再是git回购,我发现当前回购仍然不会跟踪对
my app
所做的任何更改,即使我进行了
git添加。
如何修复

  • git status
    是否在“未跟踪文件:”下显示我的应用程序目录?如果是,请添加我的应用程序以开始跟踪更改
  • 检查“
    .gitignore
    ”文件,查看是否忽略了相关目录
  • 如果不需要将“my app”目录作为单独的存储库,请尝试删除“
    .git/
    ”目录,而不是将其移动

  • 请告诉我这些命令是否有效。

    我将其中一些命令用作别名,但没有从git中看到任何“提示”

    my-app/.git
    重命名为
    my-app/.git-tmp

    做一个

    现在你可以

    git add .
    git com -am "ok"
    
    并将所有文件添加到repo

    git的“提示”是:

    hint: You've added another git repository inside your current repository.
    hint: Clones of the outer repository will not contain the contents of
    hint: the embedded repository and will not know how to obtain it.
    hint: If you meant to add a submodule, use:
    hint: 
    hint:   git submodule add <url> my-app
    hint: 
    hint: If you added this path by mistake, you can remove it from the
    hint: index with:
    hint: 
    hint:   git rm --cached my-app
    hint: 
    hint: See "git help submodule" for more information.
    
    提示:您已经在当前存储库中添加了另一个git存储库。
    提示:外部存储库的克隆将不包含
    提示:嵌入的存储库,不知道如何获取它。
    提示:如果要添加子模块,请使用:
    提示:
    提示:git子模块添加我的应用
    提示:
    提示:如果您错误地添加了此路径,可以将其从
    提示:索引中包含:
    提示:
    提示:git rm--缓存我的应用程序
    提示:
    提示:有关更多信息,请参阅“git帮助子模块”。
    
    git add.
    (注意点)在
    tryreachooks
    中不添加任何对象,因此在
    git status下
    不会在未跟踪文件下显示我的应用程序。其他两个选项呢?顶部的文件夹中没有
    .gitignore
    ,删除
    我的应用程序中的整个
    .git
    文件夹不起作用
    hint: You've added another git repository inside your current repository.
    hint: Clones of the outer repository will not contain the contents of
    hint: the embedded repository and will not know how to obtain it.
    hint: If you meant to add a submodule, use:
    hint: 
    hint:   git submodule add <url> my-app
    hint: 
    hint: If you added this path by mistake, you can remove it from the
    hint: index with:
    hint: 
    hint:   git rm --cached my-app
    hint: 
    hint: See "git help submodule" for more information.