将文件夹添加到现有的 git 文件夹中并使其成为子模块

Add folder into existed git folder and make it become submodule

首先,我的问题不同于 Create a submodule repository from a folder and keep its git commit history .

假设我有 git 个文件夹,比方说 ~/GITA
我想将文件夹 ~/Folder1 移动到其中。 (~/GITA/Folder1).
然后在文件夹(~/GITA/Folder1)中,将其更改为子模块。
然后将它(子模块~/GITA/Folder1)推送到新创建的服务器 存储库。

你必须以不同的方式来做:

  1. 创建一个新存储库并将 Folder1 中的代码添加到其中。
  2. 现在将此存储库添加为 GITA 项目下的子模块。

现在您应该有 2 个项目,其中 Folder1GITA 项目的子模块。