Skip to main content

Interactively rewrite Git commit author and committer dates.

Project description

English | 中文

Git Dates Modifier

📌 Overview

Git Dates Modifier, a Python script to rewrite commit dates (author date and committer date) selectively based on commit message matching. It supports separate modification of AuthorDate and CommitterDate for each matched commit.

✨ Features

  • Read the repository commit history and display AuthorDate and CommitterDate.
  • Interactively specify new Author and/or Committer dates for each commit.
  • Support using now to set the date to the current time.
  • Preview planned changes before rewriting history.
  • Uses git-filter-repo for safe and flexible history rewriting.

⚠️ Important Warning

This script rewrites Git history. Rewriting history will change commit SHAs and can cause problems for collaborators or any public branches. Make a backup and ensure you understand the consequences before running the script. Prefer using this on local branches or repositories where you can force-push and coordinate with other contributors.

🧩 Prerequisites

  1. Python 3.8+ (or a Python 3.x environment).

  2. git available on your PATH.

  3. git-filter-repo Python package installed. Install with:

    pip install git-filter-repo
    

🛠 Installation / Setup

Option 1: Install from PyPI (Recommended)

Install from PyPI, for example, using pip:

pip install git-dates-modifier

After installation, run it inside any git repository:

git-dates-modifier

Make sure the installation path of pip is included in your PATH.

Option 2: Run from source

Copy the script and place the script at the root of your git repository.

Ensure the script is executable or run it with Python. The script checks for a .git folder in the current working directory and will fail if not executed from a repo root.

▶️ Usage

Run the script from your repository root:

git-dates-modifier

The script will:

  1. Read commits (in chronological order).
  2. Prompt you for new Author Date and Committer Date for each commit.
    • Press Enter to keep the original date.
    • Enter now to use the current time.
    • Use a date/time string in the format: YYYY-MM-DD HH:MM:SS (example: 2025-10-24 11:22:33).
  3. Build a mapping of commit messages → date changes.
  4. Show a preview of planned changes.
  5. Ask for confirmation before executing git-filter-repo to rewrite history.

Example prompt responses

  • To skip changes for a commit: press Enter at both prompts.
  • To update only the Author date: supply value only for the Author prompt.
  • To set both dates to now: enter now at both prompts.

🧯 Safety & Troubleshooting

  • Backup first: create a clone or branch backup: git clone --mirror . /path/to/backup or git branch backup-YYYYMMDD
  • If git-filter-repo is missing, the script exits with a helpful instruction to install it.
  • If the script fails during git-filter-repo, the error will be printed. Investigate the message and restore from your backup if necessary.
  • The script uses exact message matching. If multiple commits share the same message body, they will receive the same changes.

📤 After Rewriting

Verify the new dates locally:

git log --format=fuller --date=iso

When ready to publish the rewritten history, force-push (with caution):

git push --force --all

Coordinate with any collaborators to avoid conflicts.

🌐 Encoding & Timezones

  • Input date strings should be in YYYY-MM-DD HH:MM:SS format. The script tries to parse that and append the local timezone offset.
  • now sets the date to the current local time and includes the local timezone offset.

📄 License

This project is licensed under the terms described in the LICENSE file.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

git_dates_modifier-0.1.0.tar.gz (6.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

git_dates_modifier-0.1.0-py3-none-any.whl (8.1 kB view details)

Uploaded Python 3

File details

Details for the file git_dates_modifier-0.1.0.tar.gz.

File metadata

  • Download URL: git_dates_modifier-0.1.0.tar.gz
  • Upload date:
  • Size: 6.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for git_dates_modifier-0.1.0.tar.gz
Algorithm Hash digest
SHA256 d8b8ee99ba22fb34a995be19e679d85fd5341f4a0f2351b49cfc0dea1efe5fa7
MD5 6fad1182ab5cc3554777b3216938bf45
BLAKE2b-256 c9f0deb73dfd7ca97acc169ec4d638e3f1f5dea23eefc03f8614673df9f571a4

See more details on using hashes here.

File details

Details for the file git_dates_modifier-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for git_dates_modifier-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 143bf2e76867a2de10eb496dd76838e0a3e6ee87c0fab8d00ecc1bb5f4b09aee
MD5 44645a71b620eaea8c396bbbc8534636
BLAKE2b-256 74535281c89df9a6cebc2cebe93ca8d1fe115b12bf44ee6538526b6252b50a42

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page