Automating Random Backdated Git Commits with Node.js
Publish Date: May 13
0 0
Ever wondered how to fill your GitHub contribution graph with meaningful (or fun) commits? Maybe you’re building a Git-based visualizer, running simulations, or just learning how Git automation works.
In this post, I’ll walk you through a Node.js script that generates random, backdated Git commits between two dates using simple-git, moment, and a few other handy libraries.
This project is a simple Node.js script that creates backdated Git commits with random timestamps between a defined start and end date. It can be useful for:
Populating your GitHub contribution graph
Testing Git behavior with historical data
Learning how to automate Git via Node.js
⚠️Use responsibly! This script is for educational and testing purposes only.
📦 Features
Generates random dates
Commits a JSON file (data.json) with each random date as content
Commits are made with backdated timestamps using Git’s --date option
Automatically pushes all commits after completion
📋 Requirements
Node.js (v14+ recommended)
Git installed and initialized in your project
A remote Git repository set up (for the final push)
🛠️ Setup
Clone this repo or copy the script into your own project
Commits the file with the --date flag to backdate it
Repeats the process for as many times as you want
Pushes all commits to your remote repo
Here's the core idea: we're simulating historical commits to test behavior, populate visuals, or automate Git in interesting ways.
📦 Dependencies
npm i
📈 Real-Time Results
Once you run the script, your GitHub contribution graph will start filling up with commits on random days between 2022 and 2025. It’s fun to visualize and great for testing contribution analytics or dashboards.
⚠️ Use Responsibly
This project is for educational purposes only. Faking contributions to mislead employers or teams is not cool. But if you're doing this for learning, data visualization, or to explore Git automation — go wild!
🧪 Ideas for Improvement
Add CLI arguments to set start/end dates and number of commits
Automatically generate different file content for each commit