rewrite-dates

Plans a realistic activity calendar across repositories, redistributes selected commit timestamps, and applies the rewrite to local branches. It can also restore the first stored original baseline.

Usage

git-wrangler rewrite-dates [options]
git-wrangler rewrite-dates --rollback [--repo <path>] [--yes] [--no-fetch]

By default, the command runs git fetch --prune origin before scanning. Any fetch failure stops the complete run before planning, preview, confirmation, or mutation. Use --no-fetch for offline or local-only runs.

Planning model

Without --repo, all discovered repositories are planned together on one shared activity calendar. With --repo, the same planner runs for exactly one repository.

The planner selects commits reachable from local branch refs and processes them in global original-author-date order. It chooses one planning timezone from the dominant original author timezone, builds active and rest days across the target range, allocates exact daily commit quotas, and preserves repository parent/child ordering with at least one second between selected relatives.

Only selected commits move. Unselected commits act as fixed date boundaries. Explicitly impossible ranges fail before mutation; inferred ranges may expand minimally to preserve ordering.

Options

FlagDefaultDescription
--repo <path>Target exactly one repository instead of discovering recursively.
--start-date YYYY-MM-DDInferredEarliest target activity date. Cannot be combined with --days.
--end-date YYYY-MM-DDInferredLatest target activity date. Cannot be combined with --days.
--days <number>Target the last positive number of days, ending on --until or today.
--until YYYY-MM-DDTodayEnd date for --days; requires --days.
--rewrite-after YYYY-MM-DDSelect commits whose stored original author dates are on or after this date.
--rewrite-before YYYY-MM-DDSelect commits whose stored original author dates are before this date.
--frequency <level>mediumCalendar density: low, medium, or high.
--spread <level>mediumWorkload variance across active days and sessions: low, medium, or high.
--seed <value>StoredUse a deterministic planner seed. Existing rewrite state is preferred before generating a new seed.
--rollbackfalseRestore the first stored original baseline instead of creating a new date rewrite.
--no-fetchfalseUse local remote-tracking refs without fetching origin first.
--yesfalseSkip the aggregate destructive-operation confirmation.
--guidedfalseInteractively select rewrite or rollback and configure compatible command options.

--rewrite-after and --rewrite-before select commits using stored original author dates. Together they select after <= commit < before. They do not define the target activity range.

Target ranges

--start-date and --end-date define the target activity range. If one bound is omitted, it is inferred globally from selected original author dates. If both are omitted, the selected commits’ global original minimum and maximum dates are used.

--days N targets the last N days ending on --until YYYY-MM-DD, or today when --until is omitted. It cannot be combined with --start-date or --end-date.

Frequency and spread

--frequency controls the shape and density of active sessions:

  • low creates sparse sessions, longer gaps, fewer active weekends, and longer vacation-like pauses.
  • medium is the default clustered, weekday-heavy profile.
  • high creates denser sessions, shorter gaps, stronger multi-day bursts, and more evening activity.

--spread controls how evenly selected commits are allocated after active days are chosen:

  • low keeps daily quotas more even.
  • medium uses moderate variance.
  • high allows larger day-level and session-level workload swings.

For longer ranges, the planner can add deterministic vacation- or holiday-like pauses. Commit volume increases quotas on active days; it does not activate rest days by itself. Topology and fixed boundaries can force the minimum necessary inactive or rest days to become active.

Preview and stored state

Before confirmation, the preview reports the seed source, planning timezone, selected commits, active days, rest days, forced-active days, frequency, spread, and final median, p90, and maximum commits per active day.

The command stores versioned per-repository state at refs/git-wrangler/state/rewrite-dates. The first rewrite records the original branch heads, backup refs, and original dates. Later rewrites preserve that first baseline and update only the current rewritten baseline.

Normal rewrites require clean working trees and git-filter-repo. Only local branch refs are rewritten, internal Git Wrangler refs are excluded, and origin is restored after git-filter-repo removes it.

Rollback

--rollback restores the first stored original baseline, not the most recent rewrite layer. Known original history regains its original hashes and signatures where possible.

When new commits exist on top of the current rewritten baseline, rollback restores the original base and replays only those newer commits while preserving their tree, message, authorship, and stored original dates where possible. Replayed commits may receive new hashes or lose signatures.

Rollback requires direct branch metadata and a clean working tree. It creates rollback backup refs before moving branches, resets the checked-out branch to the restored HEAD, and uses the same fetch, preview, warning, and aggregate confirmation flow as a normal rewrite. Rollback does not require git-filter-repo.

Examples

# Plan all discovered repositories together across an explicit range
git-wrangler rewrite-dates --start-date 2025-01-01 --end-date 2025-12-31

# Move selected original commits into the last 90 days ending on a fixed date
git-wrangler rewrite-dates \
  --rewrite-after 2024-01-01 \
  --rewrite-before 2025-01-01 \
  --days 90 \
  --until 2026-06-01

# Reproduce a dense, high-variance plan
git-wrangler rewrite-dates --frequency high --spread high --seed team-history-v1

# Configure rewrite or rollback interactively
git-wrangler rewrite-dates --guided

# Restore the first stored original baseline
git-wrangler rewrite-dates --rollback

Warning: Normal rewrites and rollback change local history. Review the preview carefully and coordinate any subsequent force push. Prefer git-wrangler push --force for a lease-safe remote update.