Skip to content

Take back work

Put files of an open change back as they were with af restore, and take back a change that has landed with af revert, which opens a change that reverses it, through the same gate as any other.

There are two kinds of taking back. Work that has not landed is yours to rewrite: af restore puts its files back as they were. A landing is part of main’s history, which is never rewritten: af revert opens a new change that reverses it, and that change lands as any other does, through the gate.

Restore files of an open change

Start a server and land a first version of two files:

$ af-server --dev
...
$ 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 the settings"
Working on change nytxxyrvzzwzuvwpqvpusmqqtwwxxvlx at commit 7b7549f04b8c95505540b367a7a5f434a0306d551ccab9e9d1cafac23d34c8a6
$ printf 'retries = 3\ntimeout = 30\n' > settings.toml
$ printf 'Settings for the service.\n' > README
$ af submit
Submitted commit d1715ffe16f0b29010e8ea5af26f2fe809f3a63a140c2ca1ef222f52dff31d40, 2 edits in its last snapshot
$ af status
Change nytxxyrvzzwzuvwpqvpusmqqtwwxxvlx (landed) at commit d1715ffe16f0b29010e8ea5af26f2fe809f3a63a140c2ca1ef222f52dff31d40

Start a change and edit both files:

$ af new -m "Tune the service"
Working on change zmxpwqlrynkqtktovwuwokzmopuvoyzm at commit a775347f01d2983a9f911edb33fd8659cfd58a39d071f79957621127849eb9c5
$ printf 'retries = 5\ntimeout = 60\n' > settings.toml
$ printf 'Settings for the service, tuned.\n' > README
$ af diff
M README
M settings.toml
--- a/README
+++ b/README
@@ -1 +1 @@
-Settings for the service.
+Settings for the service, tuned.
--- a/settings.toml
+++ b/settings.toml
@@ -1,2 +1,2 @@
-retries = 3
-timeout = 30
+retries = 5
+timeout = 60

Restoring a path puts it back as it is in the change’s parents, on disk and in the change, and leaves the rest of your edits alone:

$ af restore README
Rewrote change zmxpwqlrynkqtktovwuwokzmopuvoyzm at commit aa3871a60df254160afbda16c41c5e57235de61a7e5370eacc1e786bcb44e212
$ af diff
M settings.toml
--- a/settings.toml
+++ b/settings.toml
@@ -1,2 +1,2 @@
-retries = 3
-timeout = 30
+retries = 5
+timeout = 60
$ cat README
Settings for the service.

With no path, af restore takes back every edit of the change. --from restores from another commit instead of the parents.

Revert a landing

Land the tuning, then take it back:

$ af submit
Submitted commit aa3871a60df254160afbda16c41c5e57235de61a7e5370eacc1e786bcb44e212, 0 edits in its last snapshot
$ af status
Change zmxpwqlrynkqtktovwuwokzmopuvoyzm (landed) at commit aa3871a60df254160afbda16c41c5e57235de61a7e5370eacc1e786bcb44e212
Based on landing 1

af revert opens a new change on main that reverses the landing named by -r. Your workspace stays where it was, as jj’s does after jj revert; af edit moves it to the new change, by the change ID af revert printed:

$ af revert -r 'main' | tee ~/revert.out
Started change ypxsvzxzkkkrzmpwmkvzrntmttrmrxyo at commit ba2501fde3b17bb8c0293262a5828db6add146c489259dc07856eef8551d8d1e
$ export REVERT=$(sed -n 's/^Started change \([k-z]*\) .*/\1/p' ~/revert.out)
$ af edit $REVERT
Working on change ypxsvzxzkkkrzmpwmkvzrntmttrmrxyo at commit ba2501fde3b17bb8c0293262a5828db6add146c489259dc07856eef8551d8d1e
$ af diff
M settings.toml
--- a/settings.toml
+++ b/settings.toml
@@ -1,2 +1,2 @@
-retries = 5
-timeout = 60
+retries = 3
+timeout = 30
$ cat settings.toml
retries = 3
timeout = 30

It is an open change like any other: describe it if you like, then submit it, and it lands when everything it waits for is done:

$ af describe -m "Take back the tuning: timeouts in production"
Change ypxsvzxzkkkrzmpwmkvzrntmttrmrxyo is now at commit 6af55fd2868fde8516f8f13138ea8b92c787c4021690a5c368b1ec0d6d5dee3b
$ af submit
Submitted commit 6af55fd2868fde8516f8f13138ea8b92c787c4021690a5c368b1ec0d6d5dee3b, 0 edits in its last snapshot
$ af status
Change ypxsvzxzkkkrzmpwmkvzrntmttrmrxyo (landed) at commit 6af55fd2868fde8516f8f13138ea8b92c787c4021690a5c368b1ec0d6d5dee3b
Based on landing 2
$ af log -r '::main'
@  ypxsvzxz dev@localhost 2026-11-25T08:12:58Z 6af55fd2
│  Take back the tuning: timeouts in production
○  zmxpwqlr dev@localhost 2026-11-25T08:12:58Z aa3871a6
│  Tune the service
○  nytxxyrv dev@localhost 2026-11-25T08:12:58Z d1715ffe
│  Add the settings
○  zzzzzzzz  1970-01-01T00:00:00Z 00000000
   (no description set)

The tuning’s landing is still in main’s history, with the revert after it: anyone reading the history sees both.

A revert that conflicts

If main has changed the same lines since the landing, the revert holds a conflict, as a rebase would, for you to resolve before you submit it. Land a change, then another over the same line:

$ af new -m "Allow more retries"
Working on change wknxwlkylwuuqstmoppwxrnvqyqlowws at commit 1983bd8e76cc62f23dd7b7408478a219c94eddc443e20f37ee4b53180c950dc5
$ printf 'retries = 7\ntimeout = 30\n' > settings.toml
$ af submit
Submitted commit c47f9696f21659e38f5995369caf32eff7107354305c6d1b7c01359182595008, 1 edit in its last snapshot
$ af status
Change wknxwlkylwuuqstmoppwxrnvqyqlowws (landed) at commit c47f9696f21659e38f5995369caf32eff7107354305c6d1b7c01359182595008
Based on landing 3
$ af new -m "Allow even more retries"
Working on change nqqlrnyzutplyztnosslultunpxznuxy at commit 1f1cc1565e8b1e6468f5ed4ca85ab187cd973b481ec5189fdb86070e82e0c807
$ printf 'retries = 9\ntimeout = 30\n' > settings.toml
$ af submit
Submitted commit 4fcfd80bcb2e5a4bcb20a935990894249b31574e1f70e1bdf6553527675c4464, 1 edit in its last snapshot
$ af status
Change nqqlrnyzutplyztnosslultunpxznuxy (landed) at commit 4fcfd80bcb2e5a4bcb20a935990894249b31574e1f70e1bdf6553527675c4464
Based on landing 4

Revert the first of the two, main-, the landing before main’s latest, and move to the revert:

$ af revert -r 'main-' | tee ~/revert.out
Started change ysnnvlqlqslzvxnmvlmnkkrlvkznnooo at commit 1975862790429888e9bb6fd3d9e91867c618c56d07b8e60271d5be0082b944a6
$ export REVERT=$(sed -n 's/^Started change \([k-z]*\) .*/\1/p' ~/revert.out)
$ af edit $REVERT
Working on change ysnnvlqlqslzvxnmvlmnkkrlvkznnooo at commit 1975862790429888e9bb6fd3d9e91867c618c56d07b8e60271d5be0082b944a6
$ af resolve --list
settings.toml    2-sided conflict
$ cat settings.toml
<<<<<<< conflict 1 of 1
%%%%%%% diff from: the landing reverted
\\\\\\\        to: main
-retries = 7
+retries = 9
+++++++ before it
retries = 3
>>>>>>> conflict 1 of 1 ends
timeout = 30

The conflict says what each side did. Its diff is what main did since the landing, retries from 7 to 9; its snapshot is the line as it was before the landing, 3, which the revert would put back. Resolve it as in Resolve a conflict, writing the file as it should be, and submit. Or, since main has moved past the landing, the revert may no longer be wanted; abandon it:

$ af abandon
Abandoned change ysnnvlqlqslzvxnmvlmnkkrlvkznnooo

Next

Type to search…

↑↓ navigate↵ selectEsc close