git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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.
Previous: Benjamin CollinsNext: Nigel Magnay
Message 17 of 29 in “git submodules”
  1. Pierre HabouzitJul 28, 2008
  2. Pierre HabouzitJul 28, 2008
  3. Nigel MagnayJul 28, 2008
  4. Pierre HabouzitJul 28, 2008
  5. Pierre HabouzitJul 28, 2008
  6. Avery PennarunJul 28, 2008
  7. Pierre HabouzitJul 28, 2008
  8. Jakub NarebskiJul 28, 2008
  9. Junio C HamanoJul 28, 2008
  10. Pierre HabouzitAug 17, 2008
  11. Avery PennarunAug 17, 2008
  12. Junio C HamanoAug 17, 2008
  13. Pierre HabouzitAug 18, 2008
  14. Avery PennarunJul 28, 2008
  15. Pierre HabouzitJul 28, 2008
  16. Benjamin CollinsJul 29, 2008
  17. Shawn O. PearceJul 29, 2008
  18. Nigel MagnayJul 29, 2008
  19. Pierre HabouzitJul 29, 2008
  20. Pierre HabouzitJul 29, 2008
  21. Pierre HabouzitJul 29, 2008
  22. Petr BaudisJul 29, 2008
  23. Johannes SchindelinJul 29, 2008
  24. Pierre HabouzitJul 29, 2008
  25. Johannes SchindelinJul 29, 2008
  26. Pierre HabouzitJul 29, 2008
  27. Nigel MagnayJul 29, 2008
  28. Pierre HabouzitJul 29, 2008
  29. Junio C HamanoJul 29, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.