---
title: "Shape a stack"
description: "Split a change in two, move edits down the stack, and rebase a change onto another base, as jj does, with no branch to manage."
---

> Documentation Index
> Fetch the complete documentation index at: https://docs.forge.workreef.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Shape a stack

Work rarely arrives in the shape it should land in. As in jj, you rewrite changes freely until they land: each keeps its change ID, and the changes built on it follow it. Each rewrite is an operation in the repository's log, so nothing is lost.

## Split a change

Start a server and make one change that does two things:

```console server
$ af-server --dev
...
```

```console check
$ source ~/af-dev/dev/env
$ af workspace add ~/demo
Workspace at /home/you/demo
Paths: **
main has no landing yet
$ cd ~/demo
$ af new -m "Add a greeting and a farewell"
Working on change xumyokoutylrnvpstzmxtptksvmrpqsl at commit ac63db8706eb5cab05a3110baf00998c6145c77db2baaacaf0f06032ec9f0a24
$ echo "Hello" > greeting.txt
$ echo "Goodbye" > farewell.txt
```

`af split` keeps the edits at the paths you name in the change, and moves the rest to a new change on top of it. The new change takes the old description, so give the original its new one:

```console check
$ af split greeting.txt -m "Add a greeting"
Rewrote change xumyokoutylrnvpstzmxtptksvmrpqsl at commit 27c48d307d8274c8f4ba0b558af54fdc3209fd08f48bfe3a50ab49ba6a96875d
Rewrote change kovxmnwyxporyupstkqvlpxlzqkwrtmx at commit 409471952d57d17ed509695f0417f667fc1d4175dcf0841d2de3415dc36db048
$ af describe -m "Add a farewell"
Change kovxmnwyxporyupstkqvlpxlzqkwrtmx is now at commit 273070bf40bd864d4f3893eab91d0d74c5ab88b160bb13be4d28f1166a1a6778
$ af log
@  kovxmnwy dev@localhost 2026-11-24T13:58:55Z 273070bf
│  Add a farewell
○  xumyokou dev@localhost 2026-11-24T13:58:55Z 27c48d30
│  Add a greeting
○  zzzzzzzz  1970-01-01T00:00:00Z 00000000
   (no description set)
```

The greeting stayed in the original change, under its ID, `xumyokou`; the farewell is a new change, `kovxmnwy`, on top of it, and your workspace is on it.

## Move an edit down the stack

You notice the greeting needs a fix while working on the farewell. Make it where you are, then move it into the change below with `af squash`:

```console check
$ echo "Hello, world" > greeting.txt
$ af squash greeting.txt
Rewrote change xumyokoutylrnvpstzmxtptksvmrpqsl at commit fd7617bd3064e23b5e7c81f7c255036df3f41b24d2dffe30977afb7c86572a1e
Rewrote change kovxmnwyxporyupstkqvlpxlzqkwrtmx at commit 48c495326a8b4a247bade18ed95bb367472268d80e8664470cebee826ec73b0b
$ af diff
A farewell.txt
--- a/farewell.txt
+++ b/farewell.txt
@@ -0,0 +1 @@
+Goodbye
```

Only the farewell is left in your change. The fix is part of the greeting's change now.

## Absorb fixes into the changes they fix

With more than one change below, naming where each fix goes gets tedious. `af absorb` works it out, as `jj absorb` does: each edit goes into the change below that last changed the lines it touches, found by annotation. Fix the greeting again, from the farewell's change:

```console check
$ echo "Hello, world!" > greeting.txt
$ af absorb
Absorbed edits into 1 change:
  xumyokoutylrnvpstzmxtptksvmrpqsl 0baa73823ef834c97a4bead10c4bc60a11c8cd7d3e6ff95c7fd6489cd16593e0
Rebased 1 change built on them.
Remaining changes:
A farewell.txt
```

The fix went into the greeting's change, which last touched that line; the farewell, a new file, has no change below to go to, so it stays. An edit of lines that `main` last changed, or that touches lines of two changes, stays too. A path you may not write stays, named in a warning, `Skipping PATH: this actor may not write it`. Your files do not change.

## Rebase onto another base

The farewell does not need the greeting. `af rebase` moves your change onto another base: here the root, since nothing has landed yet. The greeting stays where it is, and your workspace's files follow the move:

```console check
$ af rebase -o 'root()'
Rewrote change kovxmnwyxporyupstkqvlpxlzqkwrtmx at commit db90ef5636fa00d3ac754dc60cbdbb0f44a2c1db1618a2c884b94a275acae178
$ af log
@  kovxmnwy dev@localhost 2026-11-24T13:58:59Z db90ef56
│  Add a farewell
○  zzzzzzzz  1970-01-01T00:00:00Z 00000000
   (no description set)
$ ls
farewell.txt
```

The two changes no longer depend on each other, so each can land on its own.

## Next

- [Changes and landings](https://docs.forge.workreef.dev/concepts/changes/): stacks, and how they land together.
- [`af split`](https://docs.forge.workreef.dev/reference/af/split/), [`af squash`](https://docs.forge.workreef.dev/reference/af/squash/), [`af absorb`](https://docs.forge.workreef.dev/reference/af/absorb/), [`af rebase`](https://docs.forge.workreef.dev/reference/af/rebase/) and [`af parallelize`](https://docs.forge.workreef.dev/reference/af/parallelize/) in the reference.

Source: https://docs.forge.workreef.dev/af/stacks/index.mdx
