Two Dimensional Version Control
Two Dimensional Version Control
Blog post: 4 Nov 2026 This summer I participated in the r/roguelikedev summer event where we write a Roguelike game[1], following one of the Roguelike coding tutorials. I’m not trying to learn coding, so I use this event to try learning something else. This year, one of the things I wanted to tackle was two-dimensional version control.
博客文章:2026年11月4日。今年夏天,我参加了 r/roguelikedev 夏季活动,按照其中一个 Roguelike 编程教程编写了一款 Roguelike 游戏[1]。我并不是为了学习编程,而是利用这个活动来尝试学习其他东西。今年,我想解决的问题之一是二维版本控制。
The tutorial we’re following has 14 chapters. I wanted to use version control while writing my code. But I also wanted to use version control to match the tutorial’s chapters: two “time” axes: writer time vs reader chapters At the end of the project, I want a history of changes I made while writing the tutorial (horizontal axis) and also a history of changes the reader should make while following the tutorial (vertical axis).
我们遵循的教程共有 14 章。我想在编写代码时使用版本控制,同时也想利用版本控制来匹配教程的章节:即两个“时间”轴:作者时间与读者章节。在项目结束时,我希望拥有一份我在编写教程时所做更改的历史记录(横轴),以及一份读者在学习教程时应进行的更改历史记录(纵轴)。
I can get the structure I want by setting up one Git branch per chapter, pointing to the previous chapter as the parent. Then when I update chapter 1’s code, I can push that forwards into chapter 2, 3, etc. However, the Jujutsu version control system[2] can do this automatically. Instead of managing all the branches and merges, I can focus on the “writeup” column of the diagram, where I can edit any of the chapters at any time. Jujutsu will roll forward the changes from one chapter to the others.
我可以通过为每一章设置一个 Git 分支,并将前一章作为父节点来获得我想要的结构。这样,当我更新第一章的代码时,我可以将其推送到第 2 章、第 3 章等。然而,Jujutsu 版本控制系统[2] 可以自动完成此操作。我无需管理所有的分支和合并,而是可以专注于图表中的“撰写”列,随时编辑任何章节。Jujutsu 会将更改从一个章节自动推送到后续章节。
I decided to try it for this project. Other people have blogged about Jujutsu’s features; I’m going to focus on the two dimensional output I want. Example: While working on the dungeon generation chapter, I realized I could’ve made the tile data structure better. It was easy to make those changes happen before the dungeon code. In this diagram, the horizontal axis is time and the vertical axis is chapter. I went back and forth between dungeon generation and the tile map structure. Once I was happy with both of those, I moved on to a better data structure: Mostly forward, occasionally backward Ignore the colors; they were from a visualization tool.
我决定在这个项目中尝试它。其他人已经写过关于 Jujutsu 功能的博客;我将专注于我想要的二维输出。示例:在处理地牢生成章节时,我意识到我可以改进瓦片数据结构。在编写地牢代码之前进行这些更改很容易。在此图中,横轴是时间,纵轴是章节。我在地牢生成和瓦片地图结构之间来回切换。一旦我对两者都满意,我就转向了更好的数据结构:大部分时间向前,偶尔向后。忽略颜色;它们来自可视化工具。
Example: While working on the field of view chapter, I found plenty of things I could’ve improved in earlier chapters. I had become comfortable enough with Jujutsu that my brain stopped thinking of commits as “set in stone” but instead as “I can fix that!” And I did. Going to earlier changes while working on the new feature
示例:在处理视野章节时,我发现之前章节中有很多可以改进的地方。我已经对 Jujutsu 足够熟悉,大脑不再认为提交是“一成不变”的,而是认为“我可以修复它!”我也确实这样做了。在处理新功能时返回到之前的更改。
Example: Most of the changes are to the most recent chapters (bottom of this diagram). But occasionally I went back to earlier chapters (top of this diagram). The red shows that I had merge conflicts that I had to resolve before I went back to working on the recent chapters. Changing the beginning of history
示例:大部分更改都在最近的章节中(图表底部)。但偶尔我会回到较早的章节(图表顶部)。红色部分显示我遇到了合并冲突,必须在回到最近章节的工作之前解决它们。改变历史的开端。
Example: As I became even more comfortable with making changes across commits, I came up with better names to use throughout the project. I wanted to make these changes from the beginning, so I used a combination of regular jj edit, which propagates changes forwards to later chapters, and the jj absorb command, which propagates changes backwards to earlier chapters. Lots of cleanup when changing the past
示例:随着我越来越习惯于跨提交进行更改,我想出了在整个项目中使用的更好名称。我想从一开始就进行这些更改,因此我结合使用了常规的 jj edit(将更改向前传播到后续章节)和 jj absorb 命令(将更改向后传播到之前的章节)。改变过去时需要大量的清理工作。
This required a lot of cleanup. The changes didn’t have merge conflicts, but the resulting code didn’t always compile. If I changed apple to zebra in chapter 1, and I had used apple in chapter 2, Jujutsu wouldn’t know to change that name too. So I had to make those changes and test every chapter.
这需要大量的清理工作。更改虽然没有合并冲突,但生成的代码并不总是能编译通过。如果我在第 1 章将 apple 改为 zebra,而我在第 2 章使用了 apple,Jujutsu 不会知道也要更改该名称。所以我必须手动进行这些更改并测试每一章。
Example: I loved that I can improve the version control change descriptions retroactively. Here’s me going back through all the change descriptions to format them consistently: Editing everything
示例:我喜欢可以追溯性地改进版本控制更改描述的功能。这是我回顾所有更改描述并统一格式的过程:编辑所有内容。
Thoughts: It’s hard to learn by just reading about something. For this project I wanted to try doing lots of things to see what worked well and what didn’t. This project is a bit unusual in that I’m trying to not only produce a final version of the game, but also produce 50 intermediate versions that all run, and have clean code that I can present in a tutorial series. complete project history
想法:仅通过阅读来学习是很困难的。对于这个项目,我想尝试做很多事情,看看什么有效,什么无效。这个项目有点不同寻常,因为我不仅试图制作游戏的最终版本,还试图制作 50 个都能运行的中间版本,并拥有可以在教程系列中展示的干净代码。完整的项目历史。
I think Jujutsu was a reasonable tool for this project. I can use it for developing, and also export to Git so that other people don’t have to use Jujutsu. The GitHub repository[3] has 54 git commits, not the ~5000 internal Jujutsu commits. The main downside for me so far is that a lot of things happen automatically and I couldn’t keep track of them all. I need to get better at understanding what it’s doing behind the scenes so that I can use it with more confidence while avoiding some of the pitfalls. The resulting game is playable on the web. I wrote notes but didn’t write a tutorial this time.
我认为 Jujutsu 是这个项目的合理工具。我可以用它进行开发,也可以导出到 Git,这样其他人就不必使用 Jujutsu。GitHub 仓库[3] 有 54 个 git 提交,而不是约 5000 个内部 Jujutsu 提交。到目前为止,我的主要缺点是很多事情是自动发生的,我无法跟踪所有这些事情。我需要更好地理解它在后台所做的事情,以便我能更自信地使用它,同时避免一些陷阱。最终的游戏可以在网页上运行。我写了笔记,但这次没有写教程。