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
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"
}
-
Initialize Git Repository
git init
Always start by initializing a git repository in your project folder.
-
Run the GitBackdate Script Run the script above to create commits with historical timestamps.
-
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.
-
Push to GitHub When ready to upload your historically accurate repository:
git push --force
The force flag is necessary when pushing rebased commits.
- 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.
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