A CLI tool that rewrites Git history by modifying author names/emails and redistributing commits across custom date ranges.
- Author rewriting: Change author name and email for all commits
- Date redistribution: Spread commits across custom date ranges
- Time slot constraints: Restrict commits to specific hours of the day
- Minimum interval: Enforce minimum time between consecutive commits
- Multiple branches: Preserve branch structure
- Compact output: Optional quiet mode with simple commit mapping
go build -o git-time-machine ./cmd/main.goOr download the binary:
# Clone the repository
git clone https://github.com/yourusername/git-time-machine.git
cd git-time-machine
go build -o git-time-machine ./cmd/main.gogit-time-machine [flags]| Flag | Description |
|---|---|
-i, --input |
Input Git repository directory (required) |
-o, --output |
Output directory for rewritten repository (required) |
| Flag | Description |
|---|---|
--user-name |
New author name for all commits |
--user-email |
New author email for all commits |
--date-from |
Start date for rewriting (format: 2006-01-02 or 2006-01-02T15:04:05) |
--date-to |
End date for rewriting (format: 2006-01-02 or 2006-01-02T15:04:05) |
--time-from |
Start time for time slot filtering (format: 9, 09, 09:00, 23:50) |
--time-to |
End time for time slot filtering (format: 9, 09, 09:00, 23:50) |
--min-interval |
Minimum interval between commits in hours (integer, e.g., 1, 2, 3) |
-q, --quiet |
Quiet mode (compact output only) |
--help |
Display help message |
If you specify only -i (without -o), the tool shows information about the repository without rewriting:
git-time-machine -i /path/to/input/repoThis displays:
- Repository information (number of commits and unique days)
- List of all original commits with their details
- A warning that flags will be ignored since
-ois missing
This mode is useful for inspecting a repository before deciding how to rewrite it. All other flags are ignored in this mode.
View repository information without rewriting:
git-time-machine -i /path/to/input/repoThis shows:
- Repository summary (commits and days)
- All original commits with their details
- Warning that flags are ignored (requires
-ofor rewriting)
Change the author name for all commits:
git-time-machine -i /path/to/input/repo -o /path/to/output -u "New Author"Change both author name and email:
git-time-machine -i /path/to/input/repo -o /path/to/output \
--user-name "John Doe" \
--user-email "john@example.com"Rewrite all commits to a specific date range:
git-time-machine -i /path/to/input/repo -o /path/to/output \
--date-from 2023-01-01 \
--date-to 2023-12-31Restrict commits to business hours (9 AM to 5 PM):
git-time-machine -i /path/to/input/repo -o /path/to/output \
--date-from 2023-06-01 \
--date-to 2023-06-10 \
--time-from 9 \
--time-to 17Enforce at least 2 hours between commits:
git-time-machine -i /path/to/input/repo -o /path/to/output \
--date-from 2023-01-01 \
--date-to 2023-01-03 \
--min-interval 2All features together:
git-time-machine -i /path/to/input/repo -o /path/to/output \
--user-name "John Doe" \
--user-email "john@example.com" \
--date-from 2023-01-01 \
--date-to 2023-06-30 \
--time-from 9 \
--time-to 18 \
--min-interval 1Compact output showing only the commit mapping:
git-time-machine -i /path/to/input/repo -o /path/to/output -q- Date-only:
2006-01-02 - Date with time:
2006-01-02T15:04:05
- Hour only:
9,10,23(treated as09:00,10:00,23:00) - Full time:
09:00,14:30,23:50
If --time-to is not specified, it defaults to 23 (23:59).
Commits are distributed across the date range using a semi-random algorithm that:
- Spreads commits evenly across the available time
- Respects the minimum interval constraint
- Applies time slot constraints (if specified)
- Ensures chronological order
By default, the tool shows:
- Input repository summary: Number of commits and unique days
- Original commits: Full details of each commit
- Commit mapping:
OLD_SHA --> NEW_SHA (author: old_author, date: old_date --> new_date) - Output repository summary: Number of commits and unique days
In quiet mode (-q), only the summary is shown.
$ git-time-machine -i /nonexistent/path -o /tmp/output
Error: failed to read repository: failed to list branches: chdir /nonexistent/path: no such file or directory$ git-time-machine -i ./input -o ./output --date-from 2023-01-02 --date-to 2023-01-01
Error: date-from must be before date-to$ git-time-machine -i ./input -o ./output \
--date-from 2023-01-01 --date-to 2023-01-02 \
--min-interval 24
Error: impossible to distribute 5 commits within 24.00 hours with minimum interval of 24 hours$ git-time-machine -i ./input -o ./output --time-from 18 --time-to 9
Error: --time-from must be before --time-toThe tool validates that the specified constraints can accommodate all commits:
- Date range + min-interval: Ensures enough time exists for all commits with the minimum interval
- Time slot: Ensures the time slot allows valid times for all commits
- Output: Errors with clear messages when distribution is impossible
All branches from the input repository are created in the output repository. The commit SHAs change due to rewriting, but the branch structure is preserved.
- This tool rewrites Git history and should only be used on repositories that are not shared with others
- Always backup your repository before using this tool
- Changed commit SHAs affect all dependents (branch references, tags, etc.)
- The tool creates a new repository; the original remains unchanged
MIT License - See LICENSE file for details
Created by [Your Name]