Have Your Git Rebase and Patch Versioning, Too, With git-series

79

The Git distributed revision control system is splendid in a multitude of ways but one — keeping a good history of patches and commits. Pish tosh, you say, for Git remembers everything! Yes, it does, until you rebase. To solve this problem, Josh Triplett, built a new tool called git-series, which he described in his talk at ContainerCon North America.

In his entertaining talk, Triplett, ChromeOS Architect at Intel, goes into a good level of detail on why he wrote git-series and how it works. First, why is it even necessary? Can’t you just merge everything and never rebase? You can, though, as Triplett says, “You’re actually going to go back and rewrite history as though you had done it that way to begin with. The reason you do that is so that then when you send the stack of patches, that stack of patches as merged into the public history will look like a reasonable series of development changes that make sense. As opposed to seeing a pull request that says, “Implement the feature, fix the thing I just implemented. Fix it some more. Maybe it’ll work this time.” You don’t want to see that in your public history even though that is what you actually did.”

It is reasonable for a project to require a clean public history, and you can have as mucky a private history as you like. But Git is all about working with other people. Triplett describes a typical scenario: “Development proceeds on from there and maybe you have to do a v3, v4, v5 but what happened to version 1? Did you save a copy of it anywhere? Do you still have it? Somebody makes an offhand comment, ‘I liked the way you did this in v1 better.’ They want to see the history of development. The real history of development and not the lovely curated history.”

So then you’re digging through emails, git reflog or branching your project until it looks like hallucinogenic spaghetti. “You might have a branch named feature v1, which was probably named feature and then you renamed it feature v1 when you realized you needed a v2. Then you have a v3 with that typo fix, and a v8 rebased on top of 4.6 with Alice’s fix incorporated. We have a version control system. We should be past this,” Triplett said.

Git-series is an elegant solution that tracks a patch series and its evolution through your project, and it works seamlessly with all Git features. According to Triplett, “Git-series tracks the history of a patch series, how you’ve changed it through non-fast-forwarding changes. You can rewrite history and it will keep track of what the old history looked like, including a commit message telling you what you were doing. It tracks a cover letter so that you can version that over time. It tracks the base that you started your series from to make it easy to rebase this.”

Watch Triplett’s presentation (below), which includes a live demo of git-series in action.

https://www.youtube.com/watch?v=68XsuXlWiWU

Want to learn more about Git? Check out the Introduction to Linux, Open Source Development, and Git course from The Linux Foundation.