Skip to content

Instantly share code, notes, and snippets.

@Jxck-S
Last active April 17, 2025 20:59
Show Gist options
  • Save Jxck-S/36c541653ab33222530f6b45afcd4a71 to your computer and use it in GitHub Desktop.
Save Jxck-S/36c541653ab33222530f6b45afcd4a71 to your computer and use it in GitHub Desktop.
A simple PowerShell script that brings your old school code projects to GitHub as if they were developed back in the day. It uses each file’s last modified date to retroactively create commits with accurate historical timestamps.

🕰️ GitBackdate

A simple PowerShell script that brings your old school code projects to GitHub as if they were developed back in the day.
It uses each file's last modified date to retroactively create commits with accurate historical timestamps.

Perfect for:

  • Archiving old projects
  • Preserving original file history
  • Looking like a time-traveling developer

🚀 How It Works

This script recursively scans all files in the current directory, grabs each file's LastWriteTime, stages the file, and commits it with a backdated timestamp.

# Get all files in the current directory and subdirectories
Get-ChildItem -Recurse -File | ForEach-Object {
    # Get the last modified date of the file
    $modDate = $_.LastWriteTime.ToString("yyyy-MM-dd HH:mm:ss")
    # Add the file to the staging area
    git add $_.FullName
    # Commit the file with its last modified date
    git commit -m "Updating $($_.Name)" --date="$modDate"
}

📋 Complete Usage Instructions

  1. Initialize Git Repository

    git init
    

    Always start by initializing a git repository in your project folder.

  2. Run the GitBackdate Script Run the script above to create commits with historical timestamps.

  3. Fix Committer Dates After creating all commits, run:

    git rebase --root --committer-date-is-author-date
    

    This ensures both author and committer dates match the historical dates.

  4. Push to GitHub When ready to upload your historically accurate repository:

    git push --force
    

    The force flag is necessary when pushing rebased commits.

Use Cases:

  • Portfolio Building: Show recruiters your actual development history
  • Educational Archives: Preserve student projects with accurate timestamps
  • Legacy Code Migration: Maintain original development timelines when migrating from other version control systems
  • Personal Time Capsules: Archive your coding journey with authentic timestamps

Unlike other solutions that might require complex scripts or manual date manipulation, GitBackdate automatically handles the entire process with just a few commands.

🔄 Related Keywords

Git history preservation, backdated commits, file timestamp commits, retroactive git history, migrate old projects to git, historical code repository, preserve file timestamps git, git time machine

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment