【发布时间】:2025-11-25 23:40:02
【问题描述】:
我遇到了 git 的问题。我要做的就是在文件夹中上传反应应用程序。
我正在使用以下内容:
npx create-react-app task_4_1
之后,我更改了src 文件夹文件,并尝试推送到 git 现有文件夹。
我收到的警告:
PS C:\Users\Robert\Desktop\New folder> git add .
warning: adding embedded git repository: task_4_1
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:
hint: git submodule add <url> task_4_1
hint:
hint: If you added this path by mistake, you can remove it from the
hint: index with:
hint:
hint: git rm --cached task_4_1
hint:
如果我在 git 中创建后遵循 git 命令,请参见下图
我只想将我的应用程序放在一个文件夹中。随着更多的文件夹将在稍后作为学习步骤来到这里。
试图在这里搜索答案。没有一个解决方案实际上有帮助。没有相同的问题。
updated
我希望它是这样的
所以我可以在一个 repo 中拥有 2-8 个不同的 react 应用程序。
如果我在根文件夹中执行所有命令,它会像这样
当我继续在那里添加新应用时,它会变得一团糟
如果我从根目录中删除 .git 文件,这将意味着所有 node_modules 也将被上传到 git,我们不尽量避免吗?
【问题讨论】:
-
您似乎试图移动或复制您的
.git文件夹。你不应该那样做。 -
没碰过。我可以使用普通的 create-react-app 而不做任何更改,并且会得到相同的结果。
-
npx create-react-app task_4_1设置一个新的 React 项目并初始化一个 git 存储库。如果您不想要 CRA 设置的“git 存储库”,只需删除task_4_1文件夹中的.git文件夹即可。 -
因为我那里只有 .gitignore 文件。这不意味着 tgat 我将上传 node_module 文件以及 .build 文件夹,我将使用 npm build 吗???
-
@RobertL:您个人可能没有创建两个存储库,但您运行的命令创建了。 Git 警告您“内部”存储库中的文件没有被添加到外部存储库。相反,外部 Git 制作了我有时称之为“半途而废”的子模块:一个缺少克隆它所需信息的子模块。 这是个坏主意,这就是 Git 警告你的原因。
标签: reactjs git gitlab create-react-app