2

I have a project like this:

main_module
-folder
--submodule_pub1
--submodule_pub2
--submodule_sec

Not everyone reaches the submodule_sec. Is there a way for this people to check out the main_module and all public submodules, but remove the submodule_sec but only locally? With somehow mark it locally unchanged?

I have found this answer: https://stackoverflow.com/a/1260982/337621 My problem, that I do not want to make a commit, and I do not want to have the removed submodule as untracked change. Is there a way to do this? Which commands do I need for the example above?

Community
  • 1
  • 1
Gábor Lipták
  • 9,646
  • 2
  • 59
  • 113

1 Answers1

2

You can try, with recent git 1.8.3+, a:

git submodule deinit -- folder/submodule_sec

From the git submodule man page:

Further calls to git submodule update, git submodule foreach and git submodule sync will skip any unregistered submodules until they are initialized again,

Since it unregisters a submodule, removing it from the .git/config file, that means it is only a local modification of the local config: it doesn't affect the submodule itself, which continues to be referenced by the parent repo, both in the working tree and in the .gitmodules files.
But the git submodule update command won't initialize and checkout a submodule that you just deinit.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • How do I install it on Ubuntu? The latest is 1.8.1 in the package manager. Is there an easy way to install the latest? – Gábor Lipták Oct 01 '13 at 07:19
  • 1
    @GáborLipták the answer for installing the latest git on Ubuntu was on Stack Overflow 45 minutes ago ;) http://stackoverflow.com/a/19109661/6309 – VonC Oct 01 '13 at 07:34