Am 26.09.2012 06:18, schrieb Jonathan Johnson: > I believe I have found an issue with the way `submodule add` detects a submodule that already exists in the repository. Yes, this is an issue and thanks for the detailed report. > To reproduce > > 1) add a git submodule in a specific location (we'll say it's at `./submodule/location`) > 2) go through the normal steps of removing a submodule, as listed here - https://git.wiki.kernel.org/index.php/GitSubmoduleTutorial > 3) Now the submodule is completely removed and there is no reference to it in .gitmodules or .git/config > 4) Re-add a different repository at the same location (`./submodule/location`) > > Expected - The new submodule repository will be set up at ./submodule/location and have the new repository as its origin > > What Actually Happens - The new submodule uses the existing `$gitdir` (old repository) as the actual backing repository to the submodule, but the new repository is reflected in .gitmodules and .git/config. > > So to recap, the result is that `git remote show origin` in the submodule shows a different origin than is in .gitmodules and .git/config > > One simple step to remedy this would be to add the deletion of the backing repository from the .git/modules directory, but again, I think an actual command to take care of all of these steps is in order anyways. Not sure you want to encourage people poking around in the .git directory. Unfortunately just throwing away the old repository under .git/modules, whether manually or by a git command, is no real solution here: it would make it impossible to go back to a commit which records the old submodule and check that out again. The reason for this issue is that the submodule path is used as its name by "git submodule add". While we could check this type of conflict locally, we can't really avoid it due to the distributed nature of git (somebody else could add a different repo under the same path - and thus the same name - in another clone of the repo). The only long term solution I can think of is to use some kind of UUID for the name, so that the names of newly added submodules won't have a chance to clash anymore. For the short term aborting "git submodule add" when a submodule of that name already exists in .git/modules of the superproject together with the ability to provide a custom name might at least solve the local clashes. -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html