Merging Many Worktrees Into One Line A developer built a Git tool that treats worktree folders as parallel work slots for running multiple AI agents at once, then linearizes their branches into a single history using a chained `rebase --onto` with fast-forwarding. The tool's `--gw1` flag prints a merge plan before executing, and on a rebase conflict it rolls every branch back to its entry SHA rather than leaving half-rewritten history; the developer verified this by running two deliberately conflicting branches. A failed final push is not rolled back, so a linearized result survives network or permission errors and only the push is retried. A free app I built myself. Give it a try. Once you have more than three worktrees open, the next problem arrives. How do you put them back together? I seat one worker in each folder and merge everything into one line with a single script at the end. What matters is not the merge strategy but whether a failure lands you back where you started. In the first post a worktree was a tool for removing the cost of switching branches. The property that each folder is an independent build tree has a second use. Several folders can run at the same time without interfering with each other. Two processes building the same repository collide over output paths and break. With worktrees those paths are different to begin with. So I use folders as work slots. A documentation worker sits in the docs folder and a feature worker in feature-login . Each runs builds and tests in their own place. The human only reviews, from the master folder. It suits running several AI agents in parallel especially well. The agents never fight over file locks. When one breaks the build, the other slots are fine. Merge five branches into master one at a time and the graph turns into a bundle of diamonds. Read that history later and you cannot tell which change was verified on top of which. So I go the other way. The branches go in order of descent. Each is appended onto the new tip of the previous one with rebase --onto . When that is done, every branch is fast-forwarded to the final tip. My --gw1 flag does this. The plan it prints before running looks like this. merge plan — linearize 3 worktrees onto 'master', then ff-all: master pull --ff-only: already up to date master base, tip ce5b697f docs ff-advance chain to be09cdb1 feature/login rebase --onto