git branch auto-magic: git-splice, git-transplant, git-deps, and announcing git-explode!

By , June 14, 2018 11:00 pm

For the last few years I’ve been enjoying the luxury of SUSE’s generous HackWeek policy to work on building four tools supporting higher-level workflows on top of git. I’d already (quietly) announced three of them: git-splice, git-transplant, git-deps (more details below). But I’m now excited to announce that I’ve just released the fourth: git-explode !

git-explode automatically explodes a large topic branch into a set of smaller, independent topic branches. It does this by harnessing git-deps to automatically detect inter-dependencies between commits in the large source branch and using that dependency tree to construct the smaller topic branches.

I recently presented all four tools at a Meetup of the Git London User Group, and thanks to the awesome services of the host venue Skills Matter, I’m delighted to announce that the talk is now online:

video of my talk on git auto-magic at the Git London User Group Meetup

If you don’t have time to watch the whole thing, you can look at the slides, or just keep on reading to see which ones you might be interested in. I’ll list them first, and then talk about the motivation for writing them.

The tools

The first pair are available as patches to git itself:

The second pair are available as Python modules on PyPI, but both have a command-line interface too:

It’s taken a while to get them to a reasonable degree of polish, during which this work has been mostly under the radar, but now I’m now going to make a more concerted effort to advertise the tools, hence this blog post.

The Big Idea

(Jump to 02:27 in the video to see me talk about this, or look at the slides.)

All developers face common problems:

  • It’s difficult to predict what you’ll be doing next. One minute you might be working on a feature, the next you find a bug you need to fix, and the next you find some technical debt which requires refactoring.
  • Multi-tasking is almost unavoidable.
  • We’re human, so we sometimes screw up when trying to follow best practice workflow.

What does this mean when using git? Typically it means we are constantly juggling branches, and often need to manipulate the history of branches for various reasons, for example:

My feeling is that while the git ecosystem has continued to evolve incrementally over the last few years, not much progress has been made in terms of automating this janitorial work, and that most people either do it by hand, or don’t bother doing it at all. This leads to unclean history, and/or more work and frustration for reviewers.

So I wrote these tools (and others) in an attempt to push the boundaries of automating git workflows to higher levels, as I explained on the git mailing list last year. Even if all the use cases they can cover have yet to be discovered, I hope you find them useful, or at least thought-provoking enough that you might join the effort!

I’d love some feedback, so do let me know what you think in the comments below.


9 Responses to “git branch auto-magic: git-splice, git-transplant, git-deps, and announcing git-explode!”

  1. I wonder how hard it would be to take this a few steps further and use build status (or even CI/test status!) to ensure the exploded branches are entirely self-contained and valid.

    • Adam says:

      Great idea Jeremy! That doesn’t sound too hard, but I think it should remain outside the scope of git-explode itself, because there are many different ways to do CI.

      • git-hacker says:

        If these tools work anything like rebase then the –exec option (or exec in the pick list) would be idiomatic and fulfill this requirement.

        • Adam says:

          Thanks for the comment. I’m not sure what you mean by “fulfill this requirement” – please could you elaborate?

        • Adam says:

          Oh I think I see what you mean – you are suggesting adding an “–exec” to git-explode which would allow arbitrary commands to be run after the creation of each commit in each new branch, right? That’s possible, although git-explode is non-interactive and doesn’t currently work like rebase, even though splice and transplant do, so I’m not sure it makes sense at this point. That could change in the future though.

  2. Nickolai Belakovski says:

    So, how does git-transplant differ from cherry-pick, other than the workflow of pushing the commits onto a destination branch instead of the current HEAD?

    • Adam says:

      This is covered in detail in the video, but briefly a) it can transplant *into* the target branch, not just at the tip, b) it can optionally create a new branch, and c) it removes whichever commits were transplanted from the source branch.

  3. Guido says:

    Very nice work; I haven’t looked deeper into the your docs yet, but my mind jump onto a git-bisect like tool, which get fed by git-deps.

Leave a Reply


Panorama Theme by Themocracy