I work on a team on a large repo. Recently we decided to move one of the folders into its own submodule
-- aaa
-- .git
-- bbb
-- ccc
-- www # this folder is going into its own repo.
I followed the instructions to filter out the www
folder into its own repo listed here: Detach (move) subdirectory into separate Git repository. I moved the www
folder out of the aaa
repo.
I removed the directory from the master branch by running these commands:
$ cd aaa
$ git checkout master
$ git rm -rf www
$ git commit -m "remove the www/ folder from the aaa repo."
So now on master, the tree looks like this:
-- aaa
-- .git
-- bbb
-- ccc
I'd like to add www
as a submodule by running:
$ cd aaa
$ git checkout master
$ git submodule add [email protected]: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.
That works fine on master. However, any time I try to switch to another branch, I get the following error:
$ 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
How can I remove the www
folder from all the branches in the aaa
repo? There are about 100 branches, so doing this manually would be a hassle.
I'm not worried about keeping any outstanding changes that exist in www
folders of older branches.