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.
mahmud-r-farhan
/
git-commit-generator
Git Random Commit Generator
๐ Git Random Commit Generator
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
- Install dependencies:
npm i
or
npm install jsonfile moment simple-git random
- Run the script:
node index.js
You can editโฆ
๐ง What It Does
This script:
- Generates a random dates.
- Writes that date into a simple JSON file
- 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
- Schedule it via a cron job or GitHub Actions
* Visualize the commit history as a heatmap
Follow for more!
Top comments (0)