将文件夹移动到子模块中,现在获得"未被跟踪的文件将被覆盖"消息

Kev*_*rke 13 git git-submodules

我在一个大型回购团队工作.最近我们决定将其中一个文件夹移动到自己的子模块中

-- aaa
     -- .git
     --  bbb
     --  ccc
     --  www      # this folder is going into its own repo.
Run Code Online (Sandbox Code Playgroud)

我按照说明将www文件夹过滤到这里列出的自己的repo:Detach(move)子目录到单独的Git存储库中.我把www文件夹移出了aaa回购.

我通过运行以下命令从主分支中删除了该目录:

 $ cd aaa
 $ git checkout master
 $ git rm -rf www
 $ git commit -m "remove the www/ folder from the aaa repo."
Run Code Online (Sandbox Code Playgroud)

所以现在在master上,树看起来像这样:

 -- aaa
     -- .git
     --  bbb
     --  ccc
Run Code Online (Sandbox Code Playgroud)

我想www通过运行添加为子模块:

$ cd aaa
$ git checkout master
$ git submodule add git@bitbucket.org:kevinburke/www.git www
Cloning into 'www'...
remote: Counting objects: 717, done.
remote: Compressing objects: 100% (392/392), done.
remote: Total 717 (delta 318), reused 711 (delta 317)
Receiving objects: 100% (717/717), 440.52 KiB | 58 KiB/s, done.
Resolving deltas: 100% (318/318), done.
Run Code Online (Sandbox Code Playgroud)

这对主人很好.但是,每当我尝试切换到另一个分支时,我都会收到以下错误:

$ cd aaa
$ git checkout other-old-branch
error: The following untracked working tree files would be overwritten by checkout:
    www/1...
    www/2...
    www/3...
    www/4...
Aborting
Run Code Online (Sandbox Code Playgroud)

如何www从仓库中的所有分支中删除该文件夹aaa?大约有100个分支,因此手动执行此操作会很麻烦.

我并不担心保留www旧分支文件夹中存在的任何未完成的更改.

Amb*_*ber 20

只需使用git checkout -f交换分支,然后像平常一样删除它们并合并到master中以获取子模块介绍.