Boosting Your GitHub Contribution Graph: A Fun Trick with JavaScript ๐Ÿš€๐ŸŒฑ

kavindu praneeth - Nov 3 - - Dev Community

Alright, today I'm going to talk about ๐Ÿ˜„ a little fun trick. This is actually about how to increase your GitHub Contribution Graph. If you try this out, do not test it on your main GitHub account โ€“ it could have a negative impact. Instead, write a small code and run it. Here, I'll be writing the code in JavaScript. In this code, weโ€™ll go back to previous days and make Git commit messages appear as if they were done on those days. You can go back as many days as you like and customize it through the code. Once you run the code, your GitHub Contribution Graph will fill up for the reversed dates and go green ๐ŸŒฑ.

To switch between GitHub accounts, go to ๐Ÿ’ป Windows Control Panel, open ๐Ÿ› ๏ธ Credentials Manager, and remove the GitHub-related credentials under Windows Credentials. This is because we need to sign out from the GitHub account and log into the new account via a browser. Besides that, youโ€™ll need to remove your Git credentials. Then, set up the Git Bash Command Line again with git config --global user.name and git config --global user.email. Alternatively, you can generate an ๐Ÿ”‘ SSH key and use it for multiple accounts ๐Ÿง‘โ€๐Ÿ’ป.

Here, I used const {execSync} = require('child_process') to run shell commands. The code includes commands like git add, git commit, and git push. These can be run in sequence by using this method.

I also used the ๐Ÿ“‚ fs module to create a file with โ€œCommit forโ€ in it, which changes the date. When you run this code, youโ€™ll be able to see exactly how it works. Remember, try this out with a test account as it canโ€™t be recovered if you do this on your main account โ€“ it could affect it. I created a test account just for fun and tried it out ๐Ÿ˜… โ€“ and it worked ๐ŸŸข!

Code-https://github.com/kavindu724

Image description

.