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

Re: git submodules

From
Pierre Habouzit <madcoder@debian.org>
Date
Jul 29, 2008, 08:21 UTC
Message-ID
<20080729082135.GB32312@artemis.madism.org>
In-Reply-To
<b3889dff0807282251t7096a8c9wf477cf4495749d34@mail.gmail.com>
On Tue, Jul 29, 2008 at 05:51:31AM +0000, Benjamin Collins wrote:
> 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.
  Why would _you_ map them to superproject branches ? I mean it's pretty
much Git's matter. In fact, maybe calling them branches is not a
brilliant idea, what I would like would probably rather be some kind of
reflog like thing, but with one reflog per submodule and supermodule
branch.
  I agree with you than when you don't have to do any change in the
submodule, detached HEADs just work. But when you often have to push
fixes in, it's a nightmare. Instead of just having to:
  $EDITOR mysubmodule/file.c
  git commit mysubmodule/file.c # that would ideally do a commit in the
                                # submodule then update the submodule
                                # state in the supermodule
  git submodule mysubmodule push origin HEAD # push the submodule mysubmodule
                                             # changes to the appropriate branch
  git push origin HEAD
  You have to:
      cd submodule
      git branch -D master
      git checkout -b master
      git commit file.c
      cd ..
      git commit submodule
      cd submodule
      git push origin HEAD:remote/branch/we/want/to/push/to
      cd ..
      git push origin HEAD
      *phew*
  I'm sorry but this is nowhere near a good UI. Of course the detached
head *currently* prevents you to shoot yourself in the foot, because
submodules are _that_ dangerous. But those also are tedious to work
with, like a lot, which makes currently our answer to big projects "do
not have GB-big repositories, split them in submodules" a bad joke,
because their ergonomy is nowhere near what you have with a monolithic
repository yet.
  I'm trying to see what to do better. I believe we _need_ those things:
  * a way to name the successive states of the submodule, a branch looks
    like a good idea, but maybe we can "invent" some different idea so
    that it looks and tastes like a branch, but is more automagic in the
    sense that it's just a prettier name than a sha1.
    This would allow to inspect the submodule history using 
    `gitk $this_name`. The $PS1 thing is nice, but you have to cd into
    the submodule to see where it currently lives. So you rather need
    something else.
  * a way to remember where you want to push changes you do in the
    submodule to. That's a bit like branch tracking, but not quite. This
    is required so that we can (and I strongly believe we want that in
    the end) make many porcelain commands act on the full
    (super+sub)modules in a unified way, somehow hiding the submodules
    boundaries.
    For example, git commit file1 file2 file3 ... would do the
    submodules commits if any, and then the supermodule one. Alternatively, if
    you have e.g.:
      $ git add mysubmodule/file1.c
      $ git add superfile.c
      $ git add mysubmodule     # tell the supermodule we want to commit what
                                # is in the submodule index at the same time
      $ git commit
    Then if you run:
      $ git push                # fails complaining that mysubmodule is
                                # not pushed
      $ git submodule mysubmodule push
      $ git push                # works
  * What you "track" must be a per supermodule branch thing, so that if
    you do things like that:
    # you are in master in the supermodule with non pushed commits in
    # the submodule
    <.. oh crap there is a bug in the supermodule that I need to fix in
        the production branch..>
    $ git checkout production # would checkout in the submodule what
                              # matches
    $ $EDITOR mysubmodule/something
    $ git commit !$
    $ ..push everything..
    <.. okay let's now go back to master ..>
    $ git checkout master
    <... hack hack hack to finish the current WIP ...>
    <... okay we're ready to merge production in ...>
    $ git merge production    # will DWYM with the submodules, IOW merge the
                              # `production` state into the current `master` one.
    $ git sm mysubmodule push
    $ git push
    Try to write the same workflow with the current submodules, you'll
    end up with a script at least 3 times as long, because you would
    need to do everything by hand, including switching submodules,
    naming temporary branches in them so that you can work decently and
    perform the merges and so on.
-- 
·O·  Pierre Habouzit
··O                                                madcoder@debian.org
OOO                                                http://www.madism.org
Previous: Pierre HabouzitNext: Pierre Habouzit
Message 20 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.