I believe I have found an issue with the way `submodule add` detects a 
submodule that already exists in the repository. 

To reproduce

1) add a git submodule in a specific location (we'll say it's at 
2) go through the normal steps of removing a submodule, as listed here - 
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.

If this is already resolved in the newest versions, please disregard


Jonathan Johnson

http://jondavidjohn.com | m...@jondavidjohn.com

To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to