Automate the creation of fake Git commits on past dates to populate your Git contribution graph. This script uses Git's commit date functionality to create backdated commits without modifying your system time.
⚠️ Note: This script requires write access to the repository files and GitHub authentication.
- Iterates over a user-defined date range.
- Randomly skips approximately 20% of days for a more natural pattern.
- For each date:
- Creates 15–20 fake commits with backdated timestamps using Git's environment variables.
- Pushes all commits to the
mainbranch. - Cleans up generated files after pushing.
- Linux, macOS, or WSL on Windows
gitinstalleddateutility available- A Git repository initialized at the specified path
- A remote repository set up (e.g.,
origin/main) - GitHub authentication configured
- Write access to the repository files
Run the script with the following arguments:
./auto-commit.sh <START_DATE> <END_DATE> <REPO_DIR><START_DATE>: Start date inYYYY-MM-DDformat<END_DATE>: End date inYYYY-MM-DDformat<REPO_DIR>: Path to your Git repository
Example:
./auto-commit.sh 2023-09-15 2023-10-20 /path/to/your/repoMake sure:
- The dates follow the
YYYY-MM-DDformat. REPO_DIRpoints to a valid Git repository.- You have a remote branch set up (e.g.,
origin/main).
-
Make the script executable:
chmod +x auto-commit.sh
-
Run the script:
./auto-commit.sh <START_DATE> <END_DATE> <REPO_DIR>
-
Set Repository Path
Validates and changes to the specified repository directory.
-
Loop Over Dates
Iterates through each day between
START_DATEandEND_DATE, randomly skipping about 20% of days. -
For Each Day
- Creates multiple files with timestamped content.
- Uses Git environment variables (
GIT_AUTHOR_DATEandGIT_COMMITTER_DATE) to backdate commits without changing system time. - Creates a file inside a
src/directory to simulate changes. - Makes 15–20 commits with timestamps fixed at
12:00:00usingGIT_AUTHOR_DATEandGIT_COMMITTER_DATE.
-
Push and Clean Up
git push origin main
Pushes all commits to the main branch and cleans up generated files.
- Skipping Sundays: Uses
date +%uto identify Sunday as day 7. - Time Format: Commits are fixed at
12:00:00for consistency. - Files Created: Commits modify files inside a
src/directory to simulate real changes. - Branch: Assumes commits are pushed to the
mainbranch.
This script is intended for educational or personal fun use (e.g., spicing up your GitHub profile).
Do not use it to mislead others about your actual contribution history.