2014/1/7 Heiko Voigt <hvo...@hvoigt.net>:
> 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

NOTE: the following seems to me compatible with Trevor's
"submodule.<module>.branch means attached" patch.

git submodule head

The full syntax is the sum of the following ones:
git submodule head [-b <branch>] [--attach] [--] [<path>...]
git submodule head [-b <branch>] [--attach] --index [--] [<path>...]
git submodule head --reset [--] [<path>...]
git submodule head --reset --index [--] [<path>...]

(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 <branch>.
# Also set ".git/config" 'submodule.<module>.branch' to <branch>
$ git submodule head -b <branch> --attach <module>

# Attach the submodule HEAD to 'submodule.<module>.branch'.
# If it does not exists defaults to <remote>/master
$ git submodule head --attach <module>

# Unset  ".git/config" 'submodule.<module>.branch'
# Also attach or detach the HEAD according to what is in ".gitmodules":
# with Trevor's patch 'submodule.<module>.branch' set means attached,
# unset means detached
$ git submodule head --reset <module>

NOTE: feature branch part!

# Set ".gitmodules" 'submodule.<module>.branch' to <branch>
$ git submodule head -b <branch> --attach --index <module>

# Unset ".gitmodules" 'submodule.<module>.branch'
$ git submodule head --reset --index <module>

Also note that a --detach switch is not needed with Trevor's patch. To
resync to a dettached HEAD workflow, when 'submodule.<module>.branch'
is unset in ".gitmodule", --reset (without --index) should be enough.

What do you think? Better?

Thank you,
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