docs/making-changes.md in oak/oak
Making changes
See what changed, checkpoint it, publish it, and keep up with main.
See what changed
oak status # modified, added, deleted files
oak status --short # one line per path (same as --porcelain)
oak status --json --compact # bounded JSON, for agents
oak diff # working tree vs. your last checkpoint
oak diff src/ README.md # only these paths
oak diff --branch # everything on this branch (commits + uncommitted) vs. where it forked from main
oak diff --stat # per-file +/- counts
oak diff --name-only # just the paths
oak diff --print # plain unified diff to stdout instead of the viewer
oak diff --check # whitespace errors and leftover conflict markers; exits 1 if any
On a terminal, oak diff opens a full-screen viewer, a file tree beside the diff, that takes arrow, vi and emacs keys; ? lists them. Piped, or with --print or --json, it prints instead. OAK_DIFF_TOOL names an external diff tool to use instead.
oak diff also compares branches and commits without checking anything out; see reviewing.
Checkpoint with oak commit
oak commit # snapshot every change in the working tree
oak commit src/parser/ # only changes under these paths
oak commit --push # checkpoint, then publish the branch
There's no staging area and no commit message; -m is refused and points at oak desc. Commits are checkpoints you can return to, and what the branch does is written once, as its description. They're squashed into one commit on main when the branch merges.
Nothing leaves your machine until you push.
Publish with oak push
oak push
Sends the branch's new commits and its description to the server. Only chunks the server doesn't have are uploaded, so a small change to a large file sends only the changed chunks.
| Situation | What to do |
|---|---|
First push of a repository made with oak init | oak push --repo <org>/<name>, or answer the prompt on a terminal. |
| Refused because the branch moved on the server | oak pull, then push again. |
| Overwrite the branch on the server | oak push --force |
| See what would be sent | oak push --plan --json |
Pushing to main is refused; main changes only by merging.
Stay in sync with oak pull
oak pull
oak pull brings in new commits on your branch from the server (pushed from another machine, or by an agent), then merges the latest main into your branch. Conflicts come up here, on your branch; see merging.
| Command | What it does |
|---|---|
oak pull | Fetch your branch, then merge main into it. |
oak pull --branch-only | Fetch your branch only; skip merging main. |
oak fetch | Refresh your local copy of main without touching your branch or working tree. |
oak pull --force | Throw away local commits the server doesn't have and match the remote branch. |
Undo things
oak restore path/to/file # put a file back to your last checkpoint
oak restore -s 3f9fab02 file # …or to how it was at another commit
oak reset # discard every uncommitted change (asks first; -f to skip)
oak reset src/ # …or just under a path
oak switch -d <hash> puts the working tree at an earlier checkpoint, and oak switch -c from there starts a new branch. oak split drops, reorders or splits a branch's commits into separate branches, like git rebase -i.
Ignore files
Put gitignore patterns in .oakignore at the repository root. Without one, Oak reads .gitignore, so an imported git repository keeps working. When both exist, only .oakignore counts.
Always ignored: .oak/, .git/, and OS files such as .DS_Store, ._*, Thumbs.db and desktop.ini.
Hooks
Executable files at .oak/hooks/<event> run at fixed points, like Git hooks:
| Hook | When | On failure |
|---|---|---|
pre-commit | Before oak commit writes anything | Aborts the commit |
post-commit | After a successful commit | Prints a warning |
Hooks run from the repository root with OAK_HOOK set to the event name. They're local and never pushed; files ending in .sample are ignored. oak commit --no-verify skips them once.
A typical Rust pre-commit:
#!/bin/sh
set -e
cargo fmt --all
cargo clippy --workspace -- -D warnings
Large files
There's nothing to set up. Files are split into chunks and stored once, so pushes and pulls move only the chunks that changed. One push can carry up to 25 GiB; see limits.
Exit codes
Every command uses the same exit codes: 5 means conflicts, 3 means the repository is locked and you can retry. The table is in cli.