There are useful answers how to remove submodules "locally" - How do I remove a submodule?
However I have the issue I have clones of my repo on several machines. Two I only work once or twice a month. So when I update the branches on those although the submodules are no longer tracked the files are still on the working branch as well in .git/modules
. On more than one occasion I accidentally checked some in. In other cases I have builds failing due to the presence of these unwanted files/directories.
I suppose I could keep a list of stuff to delete - but that doesn't seem right - how about another person would do the removal and I don't have info outside git what to remove?
So what is the suggested way to clean up clones?
update
For me git --version
returns git version 2.18.0
which seems to be current (it is 2018-09-01).
I add a reproducible example.
Setup
mkdir parent
cd parent
git init
git submodule add https://github.com/jakesgordon/javascript-tetris.git
git commit -am add
cd ..
git clone parent clone
cd clone
git submodule update --init
Now both directories contain the submodule with checked out files in javascript-tetris/
. .gitmodules
contains the submodule.
When I do
cd parent
git rm javascript-tetris
git commit -am delete
In parent the directory is javascript-tetris
gone and the entry in .gitmodules
removed. But there remains a populated .git/modules/javascript-tetris
directory.
on the clone side:
git pull
gives the warning: warning: unable to rmdir 'javascript-tetris': Directory not empty
. And the directory remains, also .git/modules/javascript-tetris
is still there.
git --version
returnsgit version 2.18.0
– Hardaygit submodule update --init
? That's what I missed in my first tries reproducing the problem. – Harday