Re: git submodules
- From
Shawn O. Pearce <spearce@spearce.org>
- Date
- Jul 29, 2008, 06:04 UTC
- Message-ID
- <20080729060449.GG11947@spearce.org>
- In-Reply-To
- <b3889dff0807282251t7096a8c9wf477cf4495749d34@mail.gmail.com>
Benjamin Collins <aggieben@gmail.com> wrote:
Show 14 quoted lines
> On Mon, Jul 28, 2008 at 4:40 PM, Avery Pennarun <apenwarr@gmail.com> wrote: > > > > > One irritating problem with submodules, is > > > that when someone else commited, and that you git submodule update, > > > you're on a detached head. Absolutely horrible. > > > > I think that roughly everyone agrees with the above statement by now. > > It would also be trivial to fix it, if only we knew what "fix" means. > > So far, I haven't seen any good suggestions for what branch name to > > use automatically in a submodule, and believe me, I've been looking > > for one :) > > I disagree with this completely. I think the detached head is > actually fantastic [...]
Ditto with Benjamin. Detached head is a fantastic idea.
Show 11 quoted lines
> [...] because it tells you all the right things: > a) the branch your submodule is on is ultimately irrelevant > b) it reminds you that this is not your project. It's part of your > project managed in a special way by Git, but your project is in .. > c) if you want to do work in this part of your project that comes from > somewhere else, you need to be thoughtful about how you manage its > branches. > > I try to keep all my submodules on (no branch) as much as possible. > In a way, I feel like that kind of relieves me of the chore of keeping > mapping superproject branches to submodule branches in my head.
At my former day-job we wrote our own "git submodule" in our build system before gitlink was available in the core, let alone git-submodule was a Porcelain command.
Many developers who were new to Git found having a sea of 11 Git repositories+working directories in a single build area difficult to manage. They quickly found the detached HEAD feature in a submodule to be a really handy way to know if they made changes there or not.
Most of our developers also modified __git_ps1() in their bash completion to use `git name-rev HEAD` to try and pick up a remote branch name when on a detached HEAD. This slowed down their bash prompts a little bit, but they found that "origin/foo" hint very valuable to let them know they should start a new branch before making changes.
So I'm just echoing what Benjamin said above, only we did it independently, and came to the same conclusion.
-- Shawn.