DEV Community

Sh Raj
Sh Raj

Posted on

Maintain Lost GitHub Streak | For Past Dates | GitHub Flaw or Not?

Maintain Lost GitHub Streak | For Past Dates | GitHub Flaw or Not?

Hey, Dev Community! 👋

Have you ever missed a day of committing and watched your precious GitHub streak go down the drain? 😱 Well, I discovered a nifty trick to backdate your commits and keep that streak alive! Let’s dive into it.

How I Found This Trick

So, there I was, happily maintaining my GitHub streak, when I missed a day. 😓 My streak broke, and I was determined to find a way to fix it. That's when I stumbled upon this trick. You can backdate your commits and even set them to future dates! This got me thinking—is this a serious flaw in the GitHub system? 🤔 Let’s find out together!

Step-by-Step Guide

1. Change Your System Date

First, let's roll back the time on your machine. On a Mac, follow these steps:

  1. Open System Preferences.
  2. Go to Date & Time.
  3. Unlock the settings if needed by clicking the lock icon and entering your password.
  4. Change the date to the day you missed (e.g., June 1).

2. Make a Commit

Next, make a commit as if it was that day:

  1. Open your terminal.
  2. Navigate to the Git repository you want to commit to.
  3. Make the necessary changes or create a new file.
  4. Stage and commit the changes with a commit message. For example:
   git add .
   git commit -m "Backdated commit to maintain streak"
Enter fullscreen mode Exit fullscreen mode

3. Sync Your Changes

Push the commit to your remote repository:

git push
Enter fullscreen mode Exit fullscreen mode

4. Verify on GitHub

Check your GitHub profile to ensure the contribution is recorded for the adjusted date. Your streak should now be intact! 🎉

5. Revert System Date

Don't forget to change your system date back to the current date and time:

  1. Go back to System Preferences.
  2. Set the date and time to the current day and time.
  3. Lock the settings to prevent further changes.

Is This a GitHub Flaw? 🤔

This trick works because GitHub tracks contributions based on the commit timestamp. By changing your system's date, you can make GitHub think the commit was made on a different day. But this raises a question—is this a serious flaw in GitHub’s system?

On one hand, it can be handy to maintain your streak. On the other hand, it might be seen as manipulating your contribution history, which some might frown upon. What do you think? Share your thoughts in the comments below! 💬

Bonus: Future Commits

Oh, and guess what? You can also set your system date to the future and make commits. Check out this commit history where I tried it out! 😜

Conclusion

Maintaining a GitHub streak can be motivating, but don’t stress if you miss a day. Use this trick responsibly, and focus on consistent coding practice over time.

Before and Afters

Image description

Image description


Image description

Before
Before

After
After


Practical

Screenshot 2024-06-08 at 11 41 42 PM
Screenshot 2024-06-08 at 11 32 39 PM
Screenshot 2024-06-08 at 11 38 09 PM
Screenshot 2024-06-08 at 11 40 48 PM
Screenshot 2024-06-08 at 11 41 21 PM
Screenshot 2024-06-08 at 11 41 25 PM

Happy coding! 🚀

Top comments (4)

Collapse
 
blazingbits profile image
BlazingBits

There's an even easier way to do this built right into Git! You can simply back date your commit messages with the command: git commit --date="YYYY-MM-DD HH:MM:SS" -m "Your commit message"

Personally, I don't think its that big of a deal but to each their own

Collapse
 
syeo66 profile image
Red Ochsenbein (he/him)

Why even care?

Collapse
 
oculus42 profile image
Samuel Rouse

Save time and just paint your GitHub graph: paintgithub.com

Collapse
 
ridays2001 profile image
Riday

This isn't a flaw. GitHub does not manage the date/time of the commits. GitHub reads the commit dates from Git commit data - which reads system settings or env.

Some comments may only be visible to logged-in visitors. Sign in to view all comments.