From: Stefan Beller Date: Wed, 31 May 2017 22:09:12 GMT Subject: Re: [PATCH 0/5] Some submodule bugfixes and "reattaching detached HEADs" Message-ID: In-Reply-To: On Mon, May 1, 2017 at 9:04 PM, Stefan Beller wrote: >> >>> I don't know why submodules were originally designed to be in a >>> detached HEAD state but I much prefer working on branches (as I'm sure >>> many other developers do) so the prospect of this becoming the norm is >>> exciting! :D >> > > I'll think about this more. What the current model is missing is the possibility to have a symbolic link not just to a ref within a repository, but to the outside of a repository (such as the superproject in this case). So we could have a HEAD with a content like: "super: [LF ]" Then we would use the HEAD to determine if the superproject would touch a submodule at all. Example workflow: git -C checkout --reattach-to-superproject # hack away in the submodule # This will make a commit in and add the # resulting object to the index of the superproject # because HEAD is tracking the superproject. # so in order to have HEAD containing the new # commit we have to change the superproject: git -C commit -a -m "message" # This has also interesting consequences for # submodule related commands: git checkout --recurse-submodules # Any submodule whose HEAD is attached to the # superproject would be touched, the others would # not. By being directly attached to the superproject, it would be easy to find all submodules that are changed, via a git -C status # no need to recurse, even! The whole "checkout --recurse-submodules" series is based on assumptions of the current mental model of how branches and detached HEADs work. A submodule would have a symref