From: Francesco Pretto Date: Wed, 08 Jan 2014 00:17:49 GMT Subject: Re: Re: [RFC v2] submodule: Respect requested branch on all clones Message-ID: In-Reply-To: <20140107223858.GB10782@sandbox-ub> 2014/1/7 Heiko Voigt : > One thing is missing though (and I think thats where Francesco came > from): What if the developer already has a detached HEAD in the > submodule? > > How does he attach to a branch? For this we need something similar to > Francescos attach/detach or Trevors submodule checkout with Junio's checkout > HEAD~0 from here[1]. > > I am still undecided how we should call it. Because of my > > Idea for feature branch support > - ------------------------------- > > For the branch attaching feature I would also like something that can actually > modify .git/config and for me more importantly .gitmodules. > > So e.g. if I want to work on a longer lived feature branch in a submodule which > I need in a feature branch in the superproject I would do something like this: > > $ git submodule checkout --gitmodules --merge -b hv/my-cool-feature > I said in another thread I said to Junio am not pursuing --attach|--detach anymore, but seeing that now everybody seem to be excited about attached HEAD here we are... Heiko, it's all day I think this syntax: it supports your above "git submodule checkout" and more. Take attention at the feature branch part! NOTE: the following seems to me compatible with Trevor's "submodule..branch means attached" patch. git submodule head ================ The full syntax is the sum of the following ones: git submodule head [-b ] [--attach] [--] [...] git submodule head [-b ] [--attach] --index [--] [...] git submodule head --reset [--] [...] git submodule head --reset --index [--] [...] (NOTE: --index should be the same as Heiko's above --gitmodules, it means -> touch .gitmodules) All the switches combinations follow, explained: # Attach the submodule HEAD to . # Also set ".git/config" 'submodule..branch' to $ git submodule head -b --attach # Attach the submodule HEAD to 'submodule..branch'. # If it does not exists defaults to /master $ git submodule head --attach # Unset ".git/config" 'submodule..branch' # Also attach or detach the HEAD according to what is in ".gitmodules": # with Trevor's patch 'submodule..branch' set means attached, # unset means detached $ git submodule head --reset NOTE: feature branch part! # Set ".gitmodules" 'submodule..branch' to $ git submodule head -b --attach --index # Unset ".gitmodules" 'submodule..branch' $ git submodule head --reset --index --------------------------------------------------------------------- Also note that a --detach switch is not needed with Trevor's patch. To resync to a dettached HEAD workflow, when 'submodule..branch' is unset in ".gitmodule", --reset (without --index) should be enough. What do you think? Better? Thank you, Francesco