如何将现有目录转换为git子模块?

3

我有一个项目,其中一些部分已经在主存储库中开发,但可以移动到独立开发的子模块中:

./                       ← repo root
├── client-angular/
│   └── whatever/
├── resources/
│   └── script/          ← wanna be sub-module
└── server-codeigniter/

问题

我该如何将 script/ 目录变成一个 Git 子模块,并尽可能少地付出努力?目前它是主仓库的跟踪对象


可能是 https://dev59.com/cXRC5IYBdhLWcg3wROpQ 的重复问题。 - Gary Fixler
1个回答

2

一旦你按照"将子目录分离(移动)到单独的Git仓库中"的说明,将子文件夹提取到自己的仓库中,你仍然需要:

  • push that new repo on a remote server (GitHub for instance)
  • git rm -r resources/script
  • and add the remote new repo as a submodule

    git submodule add /url/new/repo resources/scripts
    

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接