├── README.md └── index.sh /README.md: -------------------------------------------------------------------------------- 1 | # COMMIT TIME TRAVEL MACHINE 2 | 3 | Make your GitHub history back to any year. 4 | 5 | ![image](https://res.cloudinary.com/precieux/image/upload/v1671601842/Screenshot_from_2022-12-21_07-40-57_ahwide.png) 6 | 7 | ## Travel Back 8 | 9 | [Create a new repo](https://github.com/new) named anything on GitHub. 10 | 11 | [Generate a personal access token](https://github.com/settings/tokens/new) on GitHub and copy it. 12 | 13 | Run the following script 14 | 15 | ```bash 16 | $ sh -c "$(curl -fsSL https://raw.githubusercontent.com/mugishap/commit-time-travel-machine/master/index.sh)" 17 | ``` 18 | 19 | Enter Year, GitHub username, Github repo name, and access token and then you are done :) 20 | 21 | ## Explanations 22 | 23 | This project works on the way `git` records commit. Whenever you commit something, `git` puts an `Unix Timestamp` on it to record when you committed it. An [`Unix Timestamp`](https://www.unixtimestamp.com/) is the way computers store the current time. An `Unix timestamp` is a `32-bit` number which stores the number of seconds that has passed from January 1st, 1970 at UTC, the `Unix Epoch`. 24 | 25 | The script firstly creates a directory with the name of the wanted year - `line 9` `mkdir $YEAR` 26 | 27 | The script then initializes the directory as a git repository, using `git init` - `line 12` `git init` 28 | 29 | The script then stages all the files `git add .` and commits it, using the date `{YEAR}-01-01T18:00:00` (`line 16`) or `6pm, 1st January, YEAR` (default of the `YEAR` variable) 30 | 31 | This is the `ISO Date-Time format` for storing time: `YYYY-MM-DDTHH:MM:SS`. 32 | 33 | This commit is then pushed to GitHub (provided you already have made a repository) using `git push -u origin main -f`, and the directory is removed. 34 | 35 | GitHub recognizes the commit to have been created at `6 pm, 1st January, YEAR` and thus registers a contribution at that moment in time. If you scroll to the first year on your profile, you will see there is a single contribution to your `REPO` repository, on 1st January. 36 | 37 | -------------------------------------------------------------------------------- /index.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | _() { 4 | printf "YEAR: " 5 | read -r YEAR 6 | printf "GitHub Username: " 7 | read -r USERNAME 8 | printf "GitHub repository: " 9 | read -r REPO 10 | printf "GitHub Access token: " 11 | read -r ACCESS_TOKEN 12 | 13 | [ -z "$USERNAME" ] && exit 1 14 | [ -z "$ACCESS_TOKEN" ] && exit 1 15 | [ ! -d $YEAR ] && mkdir $YEAR 16 | 17 | cd "${YEAR}" || exit 18 | git init 19 | echo "**${YEAR}** - Generated by https://github.com/mugishap/commit-time-travel-machine" \ 20 | >README.md 21 | git add . 22 | GIT_AUTHOR_DATE="${YEAR}-01-01T18:00:00" \ 23 | GIT_COMMITTER_DATE="${YEAR}-01-01T18:00:00" \ 24 | git commit -m "${YEAR}" 25 | git remote add origin "https://${ACCESS_TOKEN}@github.com/${USERNAME}/${REPO}.git" 26 | git branch -M main 27 | git push -u origin main -f 28 | cd .. 29 | rm -rf "${YEAR}" 30 | 31 | echo 32 | echo "Cool, check your profile now: https://github.com/${USERNAME}" 33 | } && _ 34 | 35 | unset -f _ 36 | --------------------------------------------------------------------------------