๐Ÿ› ๏ธ Git Editor - Complete Technical Documentation

๐Ÿ“‹ Table of Contents

๐ŸŽฏ Overview & Architecture

Git Editor is a sophisticated command-line tool written in Rust for comprehensive Git commit history manipulation. It provides surgical precision for rewriting timestamps, author information, and commit messages while maintaining repository integrity.

๐Ÿ”ง Core Capabilities:
  • Timestamp Rewriting: Intelligent date distribution with realistic patterns
  • Author Management: Bulk update of author name and email
  • Interactive Selection: Pick specific commits or ranges
  • Simulation Mode: Preview changes before applying
  • Git URL Cloning: Direct operation on remote repositories
โš ๏ธ Critical Warning: This tool permanently rewrites Git history. Always backup your repository before use. Force pushes will be required after history rewriting.

๐Ÿ”„ Git Editor Workflow

Input Validation
Repository Analysis
History Rewriting
Verification

๐Ÿ’พ Installation & Setup

๐Ÿ“ฅ From Release Binaries

# Download the latest release for your platform
wget https://github.com/rohansen856/git-editor/releases/latest/download/git-editor-linux-x86_64.tar.gz
tar -xzf git-editor-linux-x86_64.tar.gz
sudo mv git-editor-linux-x86_64 /usr/local/bin/git-editor

# Verify installation
git-editor --help

๐Ÿ”จ From Source

# Prerequisites: Rust 1.87+ and a C compiler (libgit2 is built from source)
rustup update stable

# Clone and build
git clone https://github.com/rohansen856/git-editor.git
cd git-editor

# Build release binary
cargo build --release

# Install globally
sudo cp target/release/git-editor /usr/local/bin/

# Or use cargo install
cargo install --path .

๐Ÿณ Docker Usage

# Build Docker image
docker build -t git-editor .

# Run with repository mounted (-it is required: every prompt needs a TTY).
# The image runs as root; on Linux with rootful Docker, pass your uid so that
# libgit2's repository-ownership check passes and no root-owned files are written:
docker run -it --user "$(id -u):$(id -g)" -e HOME=/tmp \
  -v /path/to/repo:/workspace git-editor --repo-path /workspace -s

๐Ÿ“‹ System Requirements

  • Operating System: Linux, macOS, Windows
  • Memory: Minimum 100MB RAM
  • Storage: 50MB for binary + temporary space for repository cloning
  • Git: Not required at runtime: repositories, configuration and clones are handled by the bundled libgit2
  • Network: Required only for Git URL cloning (docs are local HTML)

๐Ÿš€ Operation Modes

Git Editor operates in distinct modes, each optimized for specific use cases:

Mode Primary Flag Description Use Case Required Args
Full Rewrite Default Complete repository history rewriting Bulk timestamp and author updates name, email, begin, end
Show History -s, --show-history Display commit history without modifications Repository analysis and planning repo-path only
Pick Specific -p, --pick-specific-commits Interactive individual commit selection Targeted commit modifications repo-path only
Range Edit -x, --range Select and edit commit ranges Batch editing of consecutive commits repo-path only
Simulation --simulate Preview changes without applying Safe testing and validation Modifier for full rewrite, -p and -x
Documentation --docs Open comprehensive documentation Help and reference None

๐Ÿ”„ Mode Priority System

Precedence Order (highest to lowest):

  1. --docs - Always takes precedence
  2. --simulate - Dry-run preview (full rewrite path)
  3. --range (-x) - Range-based editing
  4. --pick-specific-commits (-p) - Interactive single-commit selection
  5. --show-history (-s) - Read-only history display
  6. Full Rewrite - Default mode

๐Ÿ“– Complete Command Reference

๐Ÿ”ง Core Arguments

Argument Short Type Description Example Required
--repo-path -r String Local path or Git URL to repository -r /path/to/repo
-r https://github.com/user/repo.git
โŒ (defaults to ./)
--email - Email New author email (full rewrite, -p --commit, -x --select) --email user@example.com Full rewrite (prompted if missing)
--name -n String New author name -n "John Doe" Full rewrite (prompted if missing)
--begin -b DateTime First new date: YYYY-MM-DD HH:MM:SS (UTC), optionally with an offset such as +05:30, or RFC 3339 -b "2023-01-01 09:00:00 +05:30" Full rewrite unless --keep-dates
--end -e DateTime Last new date (same formats) -e "2023-12-31 17:00:00" Full rewrite unless --keep-dates
--skip-range-check - Flag Allow ranges shorter than 3h per commit: random gaps of at least 5 minutes, or even spacing when that does not fit (never duplicate seconds) --skip-range-check โŒ
--keep-dates - Flag Full rewrite: keep every commit's original date and time zone --keep-dates โŒ
--committer - Enum match-author (default): committer follows the edited author fields; keep: committer unchanged --committer keep โŒ
--commit - String With -p: commit number (1 = newest, as listed by -s) or hash prefix, no menu -p --commit 3 โŒ
--set-date / --set-message - String With -p --commit: new author date / new message --set-message "Fix typo" โŒ
--select - Range With -x: N-M, N or *, no table; combine with --name, --email, --begin/--end -x --select 2-5 โŒ
--yes -y Flag Confirm automatically (scripts and agents) --yes โŒ
--json - Flag Print one JSON document on stdout (history, preview, result or error); progress goes to stderr -s --json โŒ
--clone-dir - Path When --repo-path is a URL, keep the clone in this directory (required to rewrite a URL) --clone-dir ./repo-copy โŒ
--docs-out - Path With --docs: write the HTML to this file --docs --docs-out docs.html โŒ

๐ŸŽ›๏ธ Mode Flags

Flag Short Description Conflicts With Additional Options
--show-history -s Display repository commit history Other mode flags (-s, -p, -x, --docs): rejected None
--pick-specific-commits -p Interactive commit selection Other mode flags (-s, -p, -x, --docs): rejected None
--range -x Range-based commit editing Other mode flags (-s, -p, -x, --docs): rejected --message, --author, --time
--simulate - Dry-run mode (preview only) -s, --docs --show-diff
--docs - Open documentation in browser Every other mode and --simulate: rejected None

โš™๏ธ Range Mode Modifiers

These flags work exclusively with --range mode:

Flag Description Effect
--message Edit only commit messages Author name/email and timestamp fields are not editable; author, committer and dates stay untouched
--author Edit only author information Message and timestamp fields are not editable
--time Edit only timestamps Message and author fields are not editable
Note: If no modifier flags are specified with --range, all fields (message, author, timestamp) will be editable.

๐Ÿ” Simulation Options

Flag Description Output Requires
--show-diff Show detailed change preview Before/after comparison for each commit Any preview (dry run or before confirming)

๐Ÿ”ฌ Technical Implementation

๐Ÿ“Š Date Distribution Algorithm

Git Editor distributes timestamps with random weighted gaps while preserving commit order:

  • Chronological Preservation: the oldest commit gets --begin, the newest gets exactly --end, and dates strictly increase in between
  • Minimum Gap: At least 3 hours between commits by default (validated against --begin/--end)
  • Random Weights: Gaps are randomized across the available slack, in whole seconds
  • --skip-range-check: for ranges shorter than 3h ร— (commits โˆ’ 1): gaps of at least 5 minutes, or even spacing (at least one second apart) if 5 minutes do not fit
  • Time zone: dates without an offset are UTC; with an offset (e.g. +05:30) the generated dates are written in that zone
  • Keep dates: --keep-dates (or pressing Enter on both prompted date defaults) keeps every commit's own date and offset and changes only the identity

๐Ÿ” Git Operations & Safety

Repository Validation

# Git Editor performs these validations:
1. The path exists and is (inside) a Git repository; bare repositories work
2. Email / name / dates are valid; names and emails may not contain < > or newlines
3. Date range large enough for commit count (unless --skip-range-check)
4. HEAD is a branch with commits (detached or unborn HEAD is refused)
5. The branch did not move since the preview (otherwise nothing is written)

History Rewriting Process

# Internal rewriting workflow:
1. Build a plan: edits keyed by commit id (previews render the same plan)
2. Walk HEAD history oldest-first
3. Reuse every commit that has no edit and unchanged parents (same id, signature kept)
4. Rebuild the others from their raw object: new parents, edited author fields,
   committer per --committer; encoding, mergetag, other headers, raw message
   bytes and time-zone offsets are kept; signatures are dropped (they would not verify)
5. Rewrite matching Signed-off-by / Co-authored-by / Authored-by lines in the trailer block
6. Save the old tip as refs/git-editor/backup/<branch>
7. Move refs/heads/<branch> with a compare-and-swap; report other refs still on the old history

# Undo:
git reset --keep refs/git-editor/backup/<branch>

๐Ÿค– Automation & Agents

  • Non-interactive: -p --commit and -x --select replace the menu and table; --yes confirms. Without a terminal, prompts read plain lines from stdin and fail (instead of hanging) when stdin is closed.
  • JSON: --json prints one document on stdout: the history, the preview, the rewrite result (old/new ids, backup ref, stale refs) or the error.
  • Workflow: -s --json โ†’ --simulate --json โ†’ --yes --json. See AGENTS.md in the repository.
  • Colors are disabled automatically when output is not a terminal.

โŒจ๏ธ Interactive Controls

  • Prompts: Esc or Ctrl+C cancels (exit code 130); confirmations accept y or yes.
  • Range table: arrow keys or h/j/k/l to move, Enter to edit a cell, Esc to save & exit, q or Ctrl+C to cancel without saving. Long tables scroll; validation errors are shown below the table.
  • Pick mode messages: finish a new message with a line containing only .; blank lines and indentation are kept.
  • Dates in tables are shown in UTC; edits accept an offset such as +05:30.

๐ŸŒ Git URL Support

๐Ÿ“ก Supported Protocols

  • HTTPS: https://github.com/user/repo.git
  • SSH: git@github.com:user/repo.git (via ssh-agent)
  • HTTP: http://example.com/repo.git
  • git: git://example.com/repo.git

๐Ÿ”„ Clone Behavior

  • Read-only modes (-s, --simulate) use a temporary clone removed on exit
  • Rewriting a URL requires --clone-dir <DIR>; push from that directory afterwards
  • Authentication via ssh-agent and Git credential helpers
  • Credentials embedded in a URL are masked in all output

โšก Performance Characteristics

Repository Size Commit Count Processing Time Memory Usage
Small (<10MB) <1,000 <10 seconds <50MB
Medium (10-100MB) 1,000-10,000 10-60 seconds 50-200MB
Large (100MB-1GB) 10,000-100,000 1-10 minutes 200MB-1GB
Enterprise (>1GB) >100,000 >10 minutes >1GB

๐Ÿ’ก Usage Examples & Workflows

๐ŸŽฏ Basic Operations

๐Ÿ“š Open Documentation

git-editor --docs

Opens this comprehensive documentation in your default browser.

๐Ÿ“– Repository Analysis

# Show history of current directory
git-editor -s

# Analyze specific repository
git-editor --repo-path /path/to/repo --show-history

# Analyze remote repository
git-editor -r https://github.com/user/repo.git -s

Displays comprehensive commit history without making any changes.

๐Ÿ”„ Complete History Rewriting

๐Ÿ“ Basic Full Rewrite

git-editor \
  --name "John Doe" \
  --email john@example.com \
  --begin "2023-01-01 09:00:00" \
  --end "2023-12-31 17:00:00"

Rewrites all commits reachable from HEAD with new author info and timestamps distributed between the specified dates, then moves the current branch to the new tip.

๐ŸŒ Remote Repository Rewrite

# Clone into a directory you keep, rewrite it, then push from it
git-editor \
  --repo-path https://github.com/user/repo.git \
  --clone-dir ./repo-rewritten \
  --name "Corporate Identity" \
  --email corporate@company.com \
  --begin "2023-06-01 08:00:00" \
  --end "2023-06-30 18:00:00"
git -C ./repo-rewritten push --force-with-lease

Without --clone-dir, a URL is cloned into a temporary directory that is removed on exit; that is fine for -s and --simulate, and write modes refuse to run so a rewrite is never silently lost.

๐ŸŽฏ Targeted Editing

๐Ÿ” Interactive Commit Selection

# Interactive commit picker
git-editor --pick-specific-commits

# With specific repository
git-editor -r /path/to/repo --pick-specific-commits

Provides an interactive interface to select and edit individual commits.

๐Ÿ“Š Range-Based Editing

# Edit all fields in a range
git-editor --range

# Edit only commit messages
git-editor --range --message

# Edit only author information
git-editor --range --author

# Edit only timestamps
git-editor --range --time

# Multiple field editing
git-editor --range --message --author

Select a range of commits (e.g., commits 5-11) and edit specific fields.

๐Ÿ” Simulation & Preview

๐Ÿงช Dry-Run Testing

# Basic simulation
git-editor --simulate \
  --name "Test User" \
  --email test@example.com \
  --begin "2023-01-01 09:00:00" \
  --end "2023-01-31 17:00:00"

# Detailed diff preview
git-editor --simulate --show-diff \
  --name "John Doe" \
  --email john@example.com \
  --begin "2023-06-01 08:00:00" \
  --end "2023-06-30 18:00:00"

Previews all changes with detailed diffs without applying them.

๐Ÿ”„ Simulation with Other Modes

# Preview a pick-mode edit (menu or flags)
git-editor --simulate -p --commit 2 --set-message "Reworded"

# Preview a range edit made in the table, or from flags
git-editor --simulate --range --message
git-editor --simulate --show-diff -x --select 1-3 --name "Jane"

With -p and -x, simulation runs the normal selection and editing, shows exactly what would be written, and stops before writing.

๐Ÿ”ง Advanced Workflows

๐ŸŽญ Privacy & Anonymization

# Anonymize commit history
git-editor \
  --name "Anonymous Contributor" \
  --email anonymous@privacy.local \
  --begin "2023-01-01 00:00:00" \
  --end "2023-12-31 23:59:59"

# Corporate identity standardization
git-editor \
  --name "Development Team" \
  --email dev-team@company.com \
  --begin "2023-04-01 09:00:00" \
  --end "2023-04-30 17:00:00"

Standardize or anonymize commit authorship for privacy or corporate compliance.

๐Ÿ“… Timeline Compression/Expansion

# Compress 6 months of work into 1 month
git-editor \
  --name "Rapid Developer" \
  --email rapid@dev.com \
  --begin "2023-11-01 08:00:00" \
  --end "2023-11-30 20:00:00"

# Expand 1 week into 3 months
git-editor \
  --name "Consistent Contributor" \
  --email consistent@dev.com \
  --begin "2023-09-01 09:00:00" \
  --end "2023-11-30 17:00:00"

Adjust project timelines for demos, portfolio presentation, or analysis.

๐Ÿ”ง Advanced Features

๐Ÿง  Timestamp Distribution

Timestamps are generated with random weighted gaps inside --begin/--end, keeping commit order. Default rule: at least 3 hours between commits. Use --skip-range-check for tighter packing (5-minute minimum gap).

๐Ÿ”„ Interactive Features

๐ŸŽฎ Pick Specific Commits Interface

The interactive commit picker provides:

  • Numbered Commit List: Index, short hash, date, author, message preview
  • Single Selection: Enter a commit number to edit
  • Field Prompts: Edit name, email, timestamp, and/or message for that commit
  • Confirmation: Review changes before rewriting descendants as needed

๐Ÿ“Š Range Selection Interface

Range editing supports:

  • Commit Numbering: Display commits with sequential numbers
  • Range Syntax: start-end (e.g. 5-11) or * for all commits
  • Field Selection: Limit columns with --message, --author, and/or --time
  • Crossterm TUI: Spreadsheet-style editor (arrow keys, edit cells, confirm to apply)

๐Ÿ” Simulation & Analysis

Simulation Mode provides:

  • Change Summary: Shows how many commits would be affected
  • Validation: Same email, name and date checks as a real rewrite
  • Author Preview: Planned author/email updates
  • Detailed Diff: Per-commit before/after with --show-diff
  • No Mutation: Repository is left unchanged

๐ŸŒ Git URL Processing

Automatic Repository Detection

# Supported URL formats:
https://github.com/user/repo.git
https://github.com/user/repo
git@github.com:user/repo.git
https://gitlab.com/user/repo.git
https://bitbucket.org/user/repo.git

# URL normalization and validation
# Automatic .git suffix handling
# Repository name extraction for display (the temporary directory itself has a random name)

๐Ÿ—๏ธ Internal Architecture

๐Ÿ“ Project Structure

git-editor/
โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ main.rs              # Entry point and mode dispatch
โ”‚   โ”œโ”€โ”€ lib.rs               # Library re-exports (args, rewrite, utils)
โ”‚   โ”œโ”€โ”€ args.rs              # CLI argument parsing (clap)
โ”‚   โ”œโ”€โ”€ docs.rs              # Documentation generation
โ”‚   โ”œโ”€โ”€ rewrite/
โ”‚   โ”‚   โ”œโ”€โ”€ mod.rs           # Rewrite module exports
โ”‚   โ”‚   โ”œโ”€โ”€ rewrite_all.rs   # Full history rewriting
โ”‚   โ”‚   โ”œโ”€โ”€ rewrite_specific.rs # Interactive commit selection
โ”‚   โ”‚   โ””โ”€โ”€ rewrite_range.rs # Range-based editing (crossterm TUI)
โ”‚   โ””โ”€โ”€ utils/
โ”‚       โ”œโ”€โ”€ mod.rs           # Utility module exports
โ”‚       โ”œโ”€โ”€ types.rs         # Common types and aliases
โ”‚       โ”œโ”€โ”€ validator.rs     # Input validation
โ”‚       โ”œโ”€โ”€ datetime.rs      # Timestamp generation
โ”‚       โ”œโ”€โ”€ commit_history.rs# Git operations
โ”‚       โ”œโ”€โ”€ prompt.rs        # User interaction
โ”‚       โ”œโ”€โ”€ git_clone.rs     # Repository cloning
โ”‚       โ”œโ”€โ”€ git_config.rs    # Git configuration
โ”‚       โ”œโ”€โ”€ message_trailers.rs # Signed-off-by / Co-authored-by rewrites
โ”‚       โ”œโ”€โ”€ simulation.rs    # Dry-run functionality
โ”‚       โ””โ”€โ”€ help.rs          # Custom help text (unused; clap --help is primary)
โ”œโ”€โ”€ docs/
โ”‚   โ””โ”€โ”€ template.html        # Documentation template
โ”œโ”€โ”€ tests/
โ”‚   โ””โ”€โ”€ integration_tests.rs # Integration test suite
โ”œโ”€โ”€ Cargo.toml              # Dependencies and metadata
โ”œโ”€โ”€ Dockerfile              # Container configuration
โ””โ”€โ”€ Makefile                # Build automation

๐Ÿ”— Key Dependencies

Crate Version Purpose Features Used
git2 0.20+ Git repository operations Repository access, commit manipulation
clap 4.5+ Command-line argument parsing Derive API, help generation
chrono 0.4+ Date/time handling DateTime parsing (naive UTC; no time-zone handling)
colored 3.0+ Terminal output coloring ANSI color codes, cross-platform
tempfile 3.20+ Temporary directory management Auto-cleanup, secure temp files
open 5.0+ Browser launching Cross-platform file opening
url 2.5+ URL parsing and validation Git URL parsing
regex 1.11+ Pattern matching Email validation, date parsing

๐Ÿ›๏ธ Architecture Patterns

๐ŸŽฏ Error Handling

  • Custom Result type alias
  • Comprehensive error propagation
  • User-friendly error messages
  • Graceful degradation

๐Ÿ”ง Modularity

  • Separate modules by responsibility
  • Clear interface boundaries
  • Reusable utility functions
  • Testable components

๐Ÿงช Testing Strategy

Test Type Count Coverage Purpose
Unit Tests 100 Core logic Parsing, validation, dates, trailers, table editor, JSON
Engine Tests 12 Rewrite engine Commit reuse, preserved headers/offsets, committer modes, merges, backup refs, git fsck
End-to-End Tests 11 CLI binary Non-interactive runs with --yes/--json against throwaway repositories
Integration Tests 21 Library flows History, timestamps, validation, docs, argument parsing
Doc Tests 0 Documentation Code example validation

๐Ÿ› ๏ธ Development Guide

๐Ÿš€ Build Commands

# Development build (fast compilation)
cargo build

# Release build (optimized)
cargo build --release

# Run with arguments
cargo run -- --help
cargo run -- --repo-path . -s

# Watch mode for development
cargo watch -x "run -- --docs"

๐Ÿงช Testing

# Run all tests (unit, engine, end-to-end, integration)
cargo test

# Run unit tests only
cargo test --lib

# Run the rewrite engine and end-to-end suites
cargo test --test engine
cargo test --test e2e

# Run integration tests only
cargo test --test integration_tests

# Run specific test with output
cargo test --test integration_tests test_show_history_mode_integration -- --nocapture

# Run tests without browser opening (for development)
GIT_EDITOR_NO_BROWSER=1 cargo test --all

โœจ Code Quality

# Format code
cargo fmt

# Check formatting without changes
cargo fmt --check

# Run linter
cargo clippy

# Run linter with strict warnings (CI requirement)
cargo clippy --all-targets --all-features -- -D warnings

# Security audit
cargo audit

# Check for outdated dependencies
cargo outdated

๐Ÿ“ฆ Makefile Commands

# Build release binary
make build

# Run all tests
make test

# Check code formatting
make fmt

# Run clippy linter
make lint

# Run with default parameters
make run

# Run with custom environment variables
make run-custom

# Clean build artifacts
make clean

# Build Docker image
make docker-build

# Run in Docker container
make docker-run

# Install binary to /usr/local/bin
make install

# Show all available commands
make help

๐Ÿ”„ Development Workflow

  1. Setup: Clone repository and run cargo build
  2. Development: Make changes and test with cargo run
  3. Testing: Run cargo test to ensure no regressions
  4. Quality: Check with cargo fmt and cargo clippy
  5. Integration: Test end-to-end with make test
  6. Documentation: Update docs and test with --docs

๐ŸŽฏ Contribution Guidelines

  • Code Style: Follow Rust standard formatting (rustfmt)
  • Testing: Add tests for all new functionality
  • Documentation: Update inline docs and this template
  • Error Handling: Use the custom Result type consistently
  • Performance: Consider memory usage for large repositories

๐Ÿ”ง Troubleshooting & FAQ

โ— Common Issues

๐Ÿ” Repository Not Found

Error: Invalid repository path or URL: /invalid/path
Error: Repository path does not contain a valid Git repository: /path

Solutions:

  • Verify the repository path exists: ls -la /path/to/repo
  • Ensure .git directory is present: ls -la /path/to/repo/.git
  • Check permissions: ls -ld /path/to/repo
  • For Git URLs, verify network connectivity and authentication

๐Ÿ—“๏ธ Invalid Date Format

Error: Invalid start date format (expected YYYY-MM-DD HH:MM:SS): 2023-1-1

Solutions:

  • Use exact format: YYYY-MM-DD HH:MM:SS
  • Zero-pad single digits: 2023-01-01 09:00:00
  • Use 24-hour time format
  • Ensure end date is after start date

๐Ÿ“ง Email Validation Errors

Error: Invalid email format: user@domain

Solutions:

  • Include top-level domain: user@domain.com
  • The validator is a simple pattern (letters, digits, . _ % + - before @, a domain with a dot), not full RFC 5322
  • Quoted local parts and spaces are not accepted

๐ŸŒ Git URL Authentication

Error: Failed to clone repository '<url>': authentication failed: no usable credentials from ssh-agent or git credential helpers

Solutions:

  • SSH URLs: make sure your key is loaded (ssh-add -l)
  • HTTPS URLs: configure a credential helper (git config --global credential.helper ...)
  • Test with git clone first; credentials embedded in URLs are masked in output

๐Ÿ”ง Performance Issues

โšก Large Repository Optimization

# For large repositories, consider:

# 1. Use simulation mode first
git-editor --simulate --show-diff [other-args]

# 2. Process in smaller ranges
git-editor --range --message  # Edit specific fields only

# 3. Monitor system resources
htop  # Watch memory and CPU usage

# 4. Ensure sufficient disk space
df -h  # Check available space

๐Ÿ’พ Memory Management

Memory optimization tips:

  • Close other applications before processing large repos
  • Use range mode for selective editing instead of full rewrite
  • Consider splitting very large repositories
  • Monitor swap usage during processing

โ“ Frequently Asked Questions

๐Ÿ”„ Can I undo changes after rewriting history?

Answer: History rewriting is permanent. However, you can:

  • Every rewrite saves the old tip: git reset --keep refs/git-editor/backup/<branch>
  • Use Git reflog to find previous HEAD positions
  • Restore from backups if available
  • Use simulation mode to preview changes first

๐ŸŒ Does this work with remote repositories?

Answer: Yes, Git Editor can clone and process remote repositories:

  • Supports HTTPS, SSH, HTTP and git:// URLs
  • Authenticates with ssh-agent and Git credential helpers
  • Read-only modes use a temporary clone; rewrites need --clone-dir
  • Push the rewritten clone yourself with git push --force-with-lease

๐Ÿข Is this safe for production repositories?

Answer: Use with extreme caution:

  • Always test on a backup first
  • Use simulation mode for validation
  • Coordinate with team members before rewriting shared history
  • Consider impact on CI/CD pipelines and deployment history

๐Ÿ†˜ Getting Help

If you encounter issues:

  • ๐Ÿ“– Check this documentation first: git-editor --docs
  • ๐Ÿ› Search existing issues: GitHub Issues
  • ๐Ÿ“š Review the project README: Project Repository
  • ๐Ÿ†• Create a new issue with:
    • Exact command that failed
    • Complete error message
    • Operating system and Git version
    • Repository size and commit count (approximate)

๐Ÿ“š API Reference

๐Ÿ”ง Core Library Surface

๐Ÿ“Š History

// Walk HEAD and optionally print history
pub fn get_commit_history(args: &Args, print: bool) -> Result<Vec<CommitInfo>>

โฐ Timestamp Generation

// Generate random-gap timestamps for full rewrite (mutates args if cloning)
pub fn generate_timestamps(args: &mut Args) -> Result<Vec<NaiveDateTime>>

๐Ÿ”„ History Rewriting

// Full repository history rewrite (timestamps from generate_timestamps)
pub fn rewrite_all_commits(args: &Args, timestamps: Vec<NaiveDateTime>) -> Result<()>

// Interactive single-commit selection and editing
pub fn rewrite_specific_commits(args: &Args) -> Result<()>

// Range-based commit editing (crossterm TUI)
pub fn rewrite_range_commits(args: &Args) -> Result<()>

๐Ÿ“ˆ Data Structures

๐Ÿ’พ CommitInfo

pub struct CommitInfo {
    pub oid: git2::Oid,            // Full commit object id
    pub short_hash: String,        // Abbreviated hash
    pub timestamp: NaiveDateTime,  // Commit timestamp
    pub author_name: String,       // Author display name
    pub author_email: String,      // Author email address
    pub message: String,           // Commit message
    pub parent_count: usize,       // Number of parent commits
}

โš™๏ธ EditOptions

pub struct EditOptions {
    pub author_name: Option<String>,
    pub author_email: Option<String>,
    pub timestamp: Option<NaiveDateTime>,
    pub message: Option<String>,
}

๐ŸŽ›๏ธ Configuration

๐Ÿ”ง Environment Variables

Variable Purpose Default Example
GIT_EDITOR_NO_BROWSER Disable browser opening for docs Not set GIT_EDITOR_NO_BROWSER=1
NO_BROWSER Alternative browser disable flag Not set NO_BROWSER=1

๐Ÿ“‹ Exit Codes

Code Meaning Description
0 Success Operation completed (including "nothing to change")
1 Error Any failure, printed as Error: โ€ฆ on stderr (or as a JSON error with --json)
2 Usage error Invalid or conflicting arguments
130 Cancelled Declined confirmation, Esc or Ctrl+C