Knowledge / Practical guide

Keep separate approaches with worktrees

Try each approach in a separate working directory. Save and review code and configuration changes against the same starting point.

All guides

Start from the same source revision

A Git worktree is another working directory for the same repository. Give each approach its own worktree and branch so changes to one approach’s files do not overwrite another’s. Record the shared starting revision before editing.

Keep worktrees in persistent source storage. Copy the selected code and configuration into the sandbox. Review and save any source changes it produces before updating your worktree.

Keep configuration with code

Version scripts, notebooks, parameters, workflow definitions, dependency manifests, and lockfiles. Each can change the outcome, whoever writes the code.

Before a run, save a commit or source checkpoint: a stored revision of the selected code and configuration. Record its identifier. A branch name alone can later point to different code.

Review before combining changes

Compare the source changes and checked outputs before selecting an approach. The same starting point and data snapshot make the comparison easier to interpret.

Conceptual pseudocode

baseline = source_revision(project)
inputs = select_data_snapshot(dataset, version)
attempt = worktree(baseline, "batch-reader")

edit_code_and_config(attempt)
candidate = checkpoint(attempt)
result = run(candidate, inputs, environment)
assessment = evaluate(result, acceptance_checks)

review(diff(baseline, candidate), assessment)

Keep the source history, results, and reason for selecting an approach. Combine useful changes after review. Keep unsuccessful attempts when they help explain the comparison.

Version data separately

The same code can produce different results if its input data changes. Link each run to a data manifest: a list of input versions or snapshots, selected files, and checksums.

Versioneer’s data orchestration work explains how to keep data files and metadata consistent through validation and publication.

Check what the saved revision includes

A source checkpoint saves the selected files. Installed packages outside the source tree, running processes, databases, and large outputs need separate records or storage.

Keep the commands, parameters, logs, and output checks in the run record. This links the saved source to what happened during execution.