git-time-travel.mp4
Git Time Travel is a powerful Node.js package that lets you manipulate the date and time of any previous Git commit in your repository. With Git Time Travel, you can easily correct mistakes or update information in your Git history without having to rewrite your entire commit history.Try Git Time Travel today and take control of your Git history!
β οΈ Confirmation Required: Now asks for confirmation before rewriting history (safer!)- π¦ Node.js 18+: Minimum version requirement
- β¨ git-filter-repo: Auto-detects and uses modern tool (10-100x faster)
- β©οΈ Rollback: Undo last operation with
--rollback - π Batch Operations: Load changes from JSON/YAML files (
--batch) - π― Commit Ranges: Target specific ranges (
--range HEAD~5..HEAD~2) - π Advanced Filters: Filter by author (
--author) or message (--grep) - π€ Date Separation: Modify only author or committer dates
- π€ Export: Save selections to batch files for reuse
- π History: View past operations with
--history
Migration Guide | Full Changelog
- Git Bash (Windows) or any bash shell (Unix/Linux/macOS). Download from here
- Node.js version 18 or higher (required)
- git-filter-repo (optional but recommended for 10-100x performance)
- A text editor (VS Code, nano, vim, etc.) - can be configured via
--editorflag orEDITORenvironment variable
$ npm install -g git-time-travel# macOS
brew install git-filter-repo
# Ubuntu/Debian
sudo apt-get install git-filter-repo
# Fedora
sudo dnf install git-filter-repo
# Windows (via pip)
pip install git-filter-repoNote: git-time-travel works without git-filter-repo (falls back to git filter-branch), but git-filter-repo is 10-100x faster!
Git Time Travel is a command line tool that allows you to change the date and time of previous Git commits.
To use Git Time Travel, navigate to a Git repository and run:
$ git-time-travel [options]| Flag | Description |
|---|---|
-V, --version |
Output the version number |
-c, --commits <number> |
Number of commits to modify (default: 5) |
-e, --editor <editor> |
Specify the editor to use (overrides EDITOR and VISUAL env vars) |
-d, --debug |
Enable debug mode for verbose output |
-a, --all |
Change date for all available commits |
-i, --interactive |
Interactive mode with commit selection |
-b, --backup |
Create a backup branch before making changes |
--dry-run |
Preview changes without modifying git history |
-h, --help |
Display usage information |
| Flag | Description |
|---|---|
-r, --range <range> |
Specify commit range (e.g., HEAD~5..HEAD~2) |
--author <name> |
Filter commits by author name |
--grep <pattern> |
Filter commits by message pattern |
--batch <file> |
Load operations from JSON/YAML file |
--export <file> |
Export current selection to batch file |
--generate-example [format] |
Generate example batch file (json|yaml) |
--author-date-only |
Only modify author date (not committer date) |
--committer-date-only |
Only modify committer date (not author date) |
--rollback |
Rollback last operation |
--history |
Show operation history |
--use-filter-repo |
Force use of git-filter-repo (faster) |
--use-filter-branch |
Force use of git filter-branch (legacy) |
$ git-time-travel -c 1$ git-time-travel --dry-run$ git-time-travel --editor nano
$ git-time-travel --editor vim$ git-time-travel -c 10$ git-time-travel --all$ git-time-travel --interactive$ git-time-travel --backup -c 5$ git-time-travel --backup --interactive --dry-run# Made a mistake? Undo it!
$ git-time-travel --rollback
# View past operations
$ git-time-travel --history# Generate example template
$ git-time-travel --generate-example json
# Edit the JSON file with your changes
# Then apply them
$ git-time-travel --batch my-changes.json --backup# Modify specific range
$ git-time-travel --range HEAD~10..HEAD~5
# Preview first
$ git-time-travel --range HEAD~10..HEAD~5 --dry-run# By author
$ git-time-travel --author "John Doe" --backup
# By message pattern
$ git-time-travel --grep "fix:" --interactive
# Combine filters
$ git-time-travel --author "John" --grep "bug" --dry-run# Only change author dates
$ git-time-travel --author-date-only -c 5
# Only change committer dates
$ git-time-travel --committer-date-only -c 5# Export current selection for later
$ git-time-travel -c 10 --export changes.json --dry-run
# Apply exported changes later
$ git-time-travel --batch changes.json --backup# Use git-filter-repo (fast)
$ git-time-travel --use-filter-repo -c 100
# Use legacy git filter-branch
$ git-time-travel --use-filter-branch -c 5- Run the command with your desired options
- Code editor will open with the commit list:
- Edit the dates in the format shown
- Save the file and close the editor
- Confirm when prompted
- That's it! Your commit dates have been updated.
- Run with
--interactiveflag - Select specific commits using checkboxes
- Edit dates in your preferred editor
- Changes are applied only to selected commits
Git Time Travel supports the following date formats:
- ISO 8601:
2023-02-20T15:30:00+05:30or2023-02-20T15:30:00Z - Git default:
2023-02-20 15:30:00 +0530 - RFC 2822:
Mon, 20 Feb 2023 15:30:00 +0530 - Unix timestamp:
1234567890(seconds since epoch)
Problem: Error opening editor
Solution:
- Specify your editor explicitly:
git-time-travel --editor nano - Or set the
EDITORenvironment variable:export EDITOR=nano # Linux/macOS set EDITOR=nano # Windows CMD
Problem: Validation errors when processing dates
Solution:
- Ensure dates follow the format:
YYYY-MM-DDTHH:MM:SS+HH:MM - Example:
2023-02-20T15:30:00+05:30 - Don't remove the pipe separators (
|) between date, hash, and message
Problem: "Not a git repo!" error
Solution:
- Navigate to a git repository directory before running the command
- Verify with
git status
Problem: Script fails on Windows
Solution:
- Install Git Bash from git-scm.com
- Run the command from Git Bash terminal, not CMD or PowerShell
After modifying commit dates, you'll need to force push to update the remote:
git push -f origin YOUR_BRANCH_NAMEQ: Can I undo changes after running git-time-travel?
A: Yes, use git reflog to find the previous state and reset:
git reflog
git reset --hard HEAD@{n} # Replace n with the appropriate numberQ: Is it safe to use on shared branches?
A: Be cautious! Rewriting history on shared branches can cause issues for collaborators. Use --dry-run first and coordinate with your team.
Q: Does this work with signed commits?
A: Changing commit dates will invalidate GPG signatures. You'll need to re-sign commits if needed.
Created with β€οΈ by Souvik Sen
Git Time Travel is released under the MIT LICENSE.

