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

Announcement: git-subtrac (a sequel to git-subtree)

From
Avery Pennarun <apenwarr@gmail.com>
Date
Nov 10, 2019, 06:44 UTC
Message-ID
<CAHqTa-15fKjH-3Z-vHhgNpfx6c1OQXbDXwKJHT9JX6G+7tjGBA@mail.gmail.com>
Hi all,

Ten years ago (yikes!), I wrote git-subtree to work around some of the usability problems with git submodules. I don't have much more luck with submodules now than I did back then, but I've also never been very happy with git-subtree's limitations. Luckily I've learned a lot since then, so I've made another try at it.

Here's my new attempt, git-subtrac:
   https://github.com/apenwarr/git-subtrac

Unlike git-subtree, it encourages you to use an almost-pure git submodule workflow. But like git-subtree, it makes it easy to include the entire history (actually the "history of histories" since submodules can go backwards, forwards, and sideways over time) of the submodules in your superproject's repo.

As a result, it's easy to push, pull, fork, merge, and rebase your entire project no matter how many submodules you like to use. When someone does a 'fetch' of your superproject repo, they get all the submodule repos as well.

The trick is pretty straightforward. Like git-subtree, we generate a shadow history of commits, converting subtree links from inside trees into additional parent commits. This causes them to be pushed/pulled as part of a single ref. The shadow history is stable (anyone generating a shadow tree from commit X will always get the same shadow tree X+) and can be forked or merged just like the original tree. The idea is that you'd have a branch called 'master.trac' that is the companion to the 'master' branch, holding the submodule history needed to checkout any commit in that branch.

Then you simply set "url = ." for every entry in .gitmodules, and off it goes.

You could also use this as a tool for managing patch queues: create a superproject with just one submodule that you want to patch. Every time you rebase your patch queue, make a new commit in the superproject, then tie it into a nice package with subtrac.

Anyway, comments welcome. This one is written in go using the go-git library, which is very nice indeed, although it would presumably prevent this from ever being merged into git itself.

Have fun,
Avery
Message 1 of 1 in “Announcement: git-subtrac (a sequel to git-subtree)”
  1. Avery PennarunNov 10, 2019

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.