Skip to content

mehsaandev/code-time-machine

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

29 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

โฐ Visual Code Time Machine

Travel through your code history without Git. Visual Code Time Machine is a VS Code extension that automatically captures every change in your workspace, allowing you to jump back to any point in time with a single click.

Version VS Code License

โœจ Features

๐Ÿ”„ Automatic Change Tracking

  • Real-time monitoring - Tracks every file edit, save, creation, and deletion
  • Smart throttling - Captures changes after 3 seconds of inactivity or on save
  • Complete workspace snapshots - Stores the entire state of your project at each point in time
  • No Git required - Works independently of version control systems

โฎ๏ธ True Time Travel

  • Jump to any point - Click any snapshot to restore your workspace to that exact moment
  • File restoration - Files created after a snapshot are automatically removed when jumping back
  • Deleted file recovery - Files deleted after a snapshot are automatically restored when jumping back
  • Perfect accuracy - Every file is exactly as it was at that moment in time

๐Ÿ” Powerful Filtering

  • Search by description - Find snapshots by typing keywords
  • Time period filters - Quick filters for Today, Yesterday, This Week, This Month, or All Time
  • Live statistics - See total snapshots and currently visible count at a glance
  • Real-time filtering - Results update instantly as you type

๐Ÿ’พ Smart Storage

  • Content-addressable storage - Uses SHA-256 hashing like Git
  • Automatic deduplication - Identical files are stored only once
  • Efficient disk usage - Only unique content is saved, saving significant space
  • Local storage - Everything stored in .history_machine folder

๐Ÿ“ธ Snapshot Management

  • View files - See exactly which files existed in any snapshot
  • Export snapshots - Extract any point in time to a separate folder
  • Clear history - Remove all snapshots with a single click
  • Timeline visualization - Beautiful timeline view with relative timestamps

๐Ÿš€ Getting Started

Installation

Option 1: VS Code Marketplace

Install from VS Code Marketplace

Option 2: Command Line

code --install-extension MuhammadEhsaan.visual-code-time-machine

Option 3: VS Code Quick Open

  1. Press Ctrl+P (or Cmd+P on Mac)
  2. Type ext install MuhammadEhsaan.visual-code-time-machine
  3. Press Enter

How to Use

  1. Open any folder/workspace in VS Code
  2. Look for the โฐ Time Machine panel in the Explorer sidebar
  3. Start coding - snapshots are captured automatically!
  4. Click any snapshot to jump back in time

๐Ÿ“– How It Works

Automatic Capture

Visual Code Time Machine captures snapshots in these scenarios:

  • On typing - After 3 seconds of inactivity
  • On save - Immediately when you save a file (Ctrl+S)
  • On file creation - When you create new files or folders
  • On file deletion - When you delete files or folders

Storage Structure

your-workspace/
โ”œโ”€โ”€ .history_machine/
โ”‚   โ”œโ”€โ”€ blobs/              # Content storage (deduplicated)
โ”‚   โ”‚   โ”œโ”€โ”€ abc123def...    # File content by hash
โ”‚   โ”‚   โ””โ”€โ”€ 456789ghi...
โ”‚   โ””โ”€โ”€ manifest.json       # Timeline index
โ”œโ”€โ”€ src/
โ”œโ”€โ”€ package.json
โ””โ”€โ”€ ... (your files)

Time Travel Process

When you jump to a snapshot:

  1. Scan current state - Identifies all current files
  2. Load snapshot state - Retrieves files from that point in time
  3. Remove future files - Deletes files that didn't exist yet
  4. Restore past files - Recreates files that were deleted later
  5. Update content - Overwrites all files with their historical versions

๐ŸŽฎ Usage Examples

Example 1: Undo Multiple Changes

You're working on a feature and make several changes across multiple files.
Suddenly you realize you want to go back to before you started.

1. Open Time Machine panel
2. Find the snapshot from before you started (e.g., "30m ago")
3. Click "Jump Here"
4. Your workspace is instantly restored!

Example 2: Recover Deleted Files

You accidentally delete an important file and save the changes.

1. Open Time Machine panel
2. Click "This Week" to filter recent snapshots
3. Find a snapshot from before the deletion
4. Click "Jump Here"
5. The deleted file is automatically restored!

Example 3: Compare Different States

You want to see what files existed at different points in your project.

1. Open Time Machine panel
2. Click "View Files" on any snapshot
3. A new panel opens showing all files at that moment
4. Use the search box to find specific files
5. Compare with current state

Example 4: Export a Snapshot

You want to extract a working version from 2 days ago.

1. Open Time Machine panel
2. Click "Yesterday" or search for the specific time
3. Click "Export" on the desired snapshot
4. Choose a folder location
5. Complete workspace state is exported!

๐ŸŽจ Interface Guide

Timeline Panel

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ โฐ Time Machine              โ”‚
โ”‚ Navigate your code history   โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ Total: 45    Showing: 45    โ”‚ โ† Statistics
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ ๐Ÿ” Search                    โ”‚
โ”‚ [Filter by description...]   โ”‚
โ”‚                              โ”‚
โ”‚ โšก Time Period               โ”‚
โ”‚ [Today] [Yesterday] [Week]  โ”‚
โ”‚ [Month] [All Time] [Clear]  โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ [โ†ป Refresh] [๐Ÿ—‘๏ธ Clear]      โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Timeline:
โ”œโ”€ 5m ago                      โ† Latest (Current State)
โ”‚  File saved
โ”‚  ๐Ÿ“ 15 files  [View] [Jump]
โ”‚
โ”œโ”€ 23m ago
โ”‚  Document changed
โ”‚  ๐Ÿ“ 15 files  [View] [Jump]
โ”‚
โ”œโ”€ 1h ago
โ”‚  Files created
โ”‚  ๐Ÿ“ 14 files  [View] [Jump]

Snapshot Actions

Each snapshot has three actions:

  • View Files - Opens a panel showing all files in that snapshot
  • Export - Exports the snapshot to a folder
  • โฎ๏ธ Jump Here - Restores your workspace to this snapshot

โš™๏ธ Commands

Access these via Command Palette (Ctrl+Shift+P or Cmd+Shift+P):

  • Code Time Machine: Revert to Snapshot - Jump to a specific snapshot
  • Code Time Machine: Clear History - Delete all snapshots
  • Code Time Machine: Export Snapshot - Export a snapshot to a folder
  • Code Time Machine: View Snapshot Files - View files in a snapshot

๐Ÿ”ง Configuration

Exclusions

By default, these folders are excluded from snapshots:

  • .history_machine/ (the extension's storage)
  • node_modules/
  • .git/

Storage Location

All snapshots are stored in .history_machine/ in your workspace root.

Important: Add .history_machine/ to your .gitignore if you're using Git:

echo ".history_machine/" >> .gitignore

๐Ÿ’ก Tips & Best Practices

โœ… Do's

  • Use quick filters - Fast way to find recent changes
  • Export important snapshots - Create backups of working states
  • Search descriptions - Find specific changes quickly
  • Review before jumping - Click "View Files" to see what will change
  • Clear old history - Periodically clean up to save disk space

โŒ Don'ts

  • Don't rely solely on Time Machine - Still use proper version control (Git) for team projects
  • Don't track large files - The extension stores complete file contents
  • Don't delete .history_machine - You'll lose all your history
  • Don't jump during unsaved work - Save your work first to avoid losing changes

๐Ÿ› ๏ธ Troubleshooting

Snapshots Not Appearing

Problem: Changes aren't being captured

Solutions:

  • Ensure you have a workspace/folder open (not just individual files)
  • Check that the file is in the workspace (not an external file)
  • Verify the extension is activated (check status bar or extension list)

Timeline Empty After Jump

Problem: After jumping to a snapshot, the timeline appears empty

Solutions:

  • Click the "Refresh" button in the timeline
  • Close and reopen the Time Machine panel
  • Restart VS Code if the issue persists

Large Disk Usage

Problem: .history_machine folder is taking too much space

Solutions:

  • Click "Clear All" to remove old snapshots
  • Exclude large files/folders from your workspace
  • Export important snapshots then clear history

Jump Fails

Problem: Error when trying to jump to a snapshot

Solutions:

  • Ensure no files are currently being edited
  • Close all open editors
  • Check that .history_machine folder exists and is readable
  • Try refreshing the timeline

๐Ÿ” Privacy & Security

  • Local only - All data stays on your machine
  • No cloud sync - Nothing is sent to external servers
  • No telemetry - The extension doesn't track or report usage
  • Full control - You can delete all history anytime

๐Ÿ—๏ธ Technical Details

Architecture

  • Language: TypeScript
  • Storage: File-based with content-addressable blobs
  • Hashing: SHA-256 for content deduplication
  • UI: WebView-based sidebar with VS Code theme integration

Performance

  • Throttling: 3-second debounce on typing changes
  • Deduplication: Identical files stored only once
  • Lazy loading: Snapshots loaded on-demand
  • Async operations: Non-blocking capture and restoration

Compatibility

  • VS Code: Version 1.75.0 or higher
  • OS: Windows, macOS, Linux
  • Node.js: Built-in with VS Code

๐Ÿ“ฆ Dependencies

  • fs-extra - Enhanced file system operations
  • diff - Content diffing for change detection

๐Ÿค Contributing

Contributions are welcome! Please read our Contributing Guide for details on:

  • ๐Ÿ› How to report bugs
  • ๐Ÿ’ก How to suggest features
  • ๐Ÿ› ๏ธ Development setup
  • ๐Ÿ“ Code style guidelines
  • ๐Ÿ”€ Pull request process

๐Ÿ“ Changelog

Version 1.0.0 (Initial Release)

  • โœจ Automatic snapshot capture on changes
  • โฎ๏ธ Time travel to any snapshot
  • ๐Ÿ” Search and filter capabilities
  • ๐Ÿ“ธ View files in snapshots
  • ๐Ÿ’พ Export snapshots to folders
  • ๐ŸŽจ Professional timeline UI
  • ๐Ÿ“Š Live statistics and counters

๐Ÿ“„ License

MIT License - see LICENSE file for details

๐Ÿ™ Acknowledgments

  • Built with โค๏ธ for the VS Code community
  • Inspired by the need for local, Git-independent version control
  • Thanks to all contributors and users for feedback

๐Ÿ“ง Support


Made with โค๏ธ by Muhammad Ehsaan | GitHub | LinkedIn | Website

"Because sometimes you need to go back in time without Git."