Skip to content

Pulling and pushing

Terminal window
t4 pull # the default environment
t4 pull --env prod
t4 pull --all # every environment that has a token
t4 pull --only pageLayout
t4 pull --no-detail # metadata only: fast, no source
t4 pull --binary # also fetch images and fonts
t4 pull --force # overwrite files you have edited locally

A pull will not overwrite a file you have edited since the last pull. The manifest records a hash of every file as pulled, which is what distinguishes “you changed this” from “the remote changed”. Protected files are listed at the end of the run; --force discards them.

The pull finds Media Library items by reading media tags out of the layouts. Uploaded data and code files it finds that way (CSV, JSON, XML, PHP, JS and similar) go into media-binary/ on every pull; only images and fonts wait for --binary.

Files a module reads by itself have no tag: the PHP behind a module, or the CSV the redirects module loads. Name them in .t4/config.json, either a whole category or single items:

"media_categories": [4567, 4568],
"media_ids": [123456]

Or let the tool edit the config: in the app, open Project and use Extra media to pull; in a terminal, t4 media add 123456, t4 media add 4567 --category, t4 media remove 123456, and t4 media to list them. Both write to the selected environment, since two T4 instances do not share ids.

The id is the number after # in the T4 address (.../page/media#123456): with a file open it is an item, with a folder open it is a category. A category id listed under media_ids is noticed, pulled as the category it is, and reported, so a mix-up costs nothing but a warning.

To find a category’s id, add one of its items to media_ids and pull: the item’s record in _raw/media.json lists its categories, and its mediaPath shows which folder that is. The API offers no way to list a category’s subcategories, so if each module has its own subcategory, list each of those ids.

Items from a category land in folders that match the Media Library, under the uploaded filename, so two modules can each have an index.php:

t4-source/test/media/Modules/redirects/index.php
t4-source/test/media/Modules/redirects/redirects.csv
t4-source/test/media-binary/Modules/redirects/icon.png

Text files can be diffed and pushed like any other media. Files T4 holds no text for, such as images, go into media-binary/ without needing --binary. If a category cannot be listed, its files from the last pull are left as they are and the pull reports the failure.

Listing a category uses an endpoint taken from T4’s published specification that has not yet been confirmed against a live instance. Once a category is configured, t4 doctor checks it.

Terminal window
t4 sync # pull, then report both sides
t4 diff [paths...] [--show]
t4 discard <paths...> # throw away local edits, back to the last pull
t4 save -m "why" # commit the pulled source
t4 push [paths...] [--dry-run]

sync is the daily command: it refreshes, then tells you what changed in T4, what is new or gone, and what you have edited locally but not pushed. It never writes to T4.

discard puts a file back to exactly what the last pull fetched, offline: it finds the text in the records the pull saved under _raw/ by its hash in the manifest, and writes nothing if no hash matches. If the last pull kept your edit because T4 had also changed the file, discarding takes T4’s newer version. In the app, every edited file in Changes has a revert to original button that does the same, after asking.

Pushing is disabled per environment by default. Turn it on for the environments you want writable, and leave production off unless you mean it:

Terminal window
t4 env set test --push

or set "push_allowed": true in .t4/config.json.

push offers only files that genuinely differ, shows a diff, and asks per file (y/N/q). Every record is snapshotted to _backup/ before being modified. A path selects that file, anything under it, or any path ending in it, so t4 push site.css works without the folder; --exact matches the path only. The panel always pushes with --exact, so only the rows you ticked go.

The manifest records what each file looked like when it was pulled, so “these differ” splits three ways:

you changed it the normal case: push it
T4 changed it, you did not pushing would put the old version back, a silent revert. t4 pull first
both changed it a conflict. Pushing discards whoever edited it in the CMS

A conflict stops the push and names the files; --ignore-conflicts proceeds and keeps your side. On a shared instance this is the likeliest way to lose work with this tool, so it is refused rather than warned about. The idea is borrowed from Salesforce DX source tracking, whose rule is that a deploy must not silently overwrite what changed in the org.

The comparison is as old as your review, so right before sending a file, push reads the record from T4 again. If it changed while you were reading the diff, that file is not sent and the push exits with status 2. The record that read returns is the one saved to _backup/ and written back, with only your field changed.

After the write, push reads the record once more and checks the field holds what was sent; a 2xx that stored something else is reported as a failure. If the connection drops mid-write, push reads the record to find out whether it landed rather than guessing.

To push from a script or a pipeline, see Pushing from CI. To require a commit before a push, see Version control.

An independent, unofficial tool. Not produced, endorsed or supported by TERMINALFOUR Solutions Ltd, and not TERMINALFOUR software. “T4” and “TERMINALFOUR” are their trademarks, used here only to identify the software this works with. Copyright © 2026 Small Robot Corp. Source available under the PolyForm Shield License 1.0.0.