Redate commits

From KilimcininKorOglu/cli-tweaks · View interactive version

Redate commits is an AI agent skill from the GitHub repository KilimcininKorOglu/cli-tweaks. Rewrites git author and committer dates across a date range with git filter-branch, distributing commits realistically across the period.

How to use this skill

Skill file

Redate Commits

Rewrites git commit dates to distribute them across a specified date range, making the history appear as if development occurred over that period.

Usage

/redate-commits 2026-02-01 2026-03-31              # Default: weighted weekdays
/redate-commits 2026-01-01 2026-06-30 --weekdays-only
/redate-commits 2026-02-01 2026-03-31 --include-weekends

Context Gathering (MANDATORY FIRST STEP)

Before doing anything, gather the commit history:

git log --oneline --format="%H %ai %s" | head -20   # Recent commits with dates
git log --oneline | wc -l                             # Total commit count
git log --reverse --format="%H %s" | head -5          # Oldest commits
git log --reverse --format="%H %s" | tail -5          # Newest commits

Parameters

| Parameter | Description | Default |

|-----------|-------------|---------|

| start-date | First date (YYYY-MM-DD) | Required |

| end-date | Last date (YYYY-MM-DD) | Required |

| --weekdays-only | Mon-Fri only | No |

| --include-weekends | All 7 days equally | No |

| --weighted-weekdays | Heavy weekdays, light weekends | Yes (default) |

Distribution Strategy

Weighted Weekdays (Default)

Grouping Logic

Commits should be grouped by feature/topic, not randomly scattered. Related commits (same feature branch, same module) should land on the same day or consecutive days.

Analyze commit messages to identify logical groups:

Time Distribution Within a Day

Implementation

Step 1: Collect Commits

git log --reverse --format="%H %s"

Step 2: Generate Date Mapping

Create a Python script that:

  1. Lists all commit hashes in chronological order
  2. Groups them by feature/topic based on commit messages
  3. Assigns dates from the range, respecting grouping
  4. Writes a shell filter script

Step 3: Apply with filter-branch

FILTER_BRANCH_SQUELCH_WARNING=1 git filter-branch -f \
  --env-filter "$(cat /tmp/git_date_filter.sh)" \
  -- --all

The filter script format:

if [ "$GIT_COMMIT" = "<hash>" ]; then
  export GIT_AUTHOR_DATE="<date>"
  export GIT_COMMITTER_DATE="<date>"
fi

Step 4: Clean Up

git reflog expire --expire=now --all
git gc --prune=now --aggressive

Step 5: Force Push (only if user confirms)

git push --force

Safety Protocol

Troubleshooting

macOS: `declare -A` not supported

Use Python for the date mapping script, not bash associative arrays. macOS default shell (zsh) has issues with declare -A in heredocs.

filter-branch snapshot error

If Docker was built from the repo, stale image layers can cause snapshot errors. Run:

docker compose build --no-cache

Verify Results

# Check first and last commit dates
git log --format="%ai %s" | tail -1    # Should be start-date
git log --format="%ai %s" | head -1    # Should be end-date

# Check weekend distribution
git log --format="%ad" --date=format:"%u %Y-%m-%d" | sort | uniq -c
# Column 1 = count, Column 2 = day-of-week (1=Mon, 7=Sun)
Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.