Question

I am working on a git project (hosted on GitHub) and using GitHub for Windows. Yesterday, I got a lot accomplished but GitHub for Windows bailed on me (says it cannot make a commit) and I was not able to commit.

I do not want to lose my GitHub commit streak, so I was wondering if there was any way to commit in a past date and sync with my GitHub (if this is possible).

Also: I have staged my commits in the git-bash but have not committed yet.

Was it helpful?

Solution

While the question "How do I make a Git commit in the past?" explains how to amend the commit author date:

git commit --amend --no-edit --date="Fri Nov 6 20:00:00 2015 -0600" 

Run that after a commit to amend the last commit with the timestamp noted.
The --no-edit will leave the message as-is.

The OP asks:

That question does not specify the GitHub result... would it work in the same way?

Yes: multiple projects exist allowing you to generate and push commits "done in the past", in order to update your contribution chart.

See for instance contribution.io, github-contribution, or gitgardener.

All you need to do, is to push those amended commit on the master branch of your GitHub repo, as I mention here.

OTHER TIPS

git commit --allow-empty --date="Sat Nov 14 14:00 2015 +0100" -m '2 Dec commit'

It will create empty commit with provided date

Works only when the system date is reverted to yesterday by changing the Time Zone and no commits are made on the current day already.

  • Open Date & Time Settings
  • Set time zone automatically - Turn it off
  • Using the Time Zone dropdown select a time zone that changes the system date to yesterday.
  • Now open github and commit. Check the contributions graph.
  • Set time zone automatically - Turn it on.

The above method worked out for me. Cheers !

You can simply accomplish this If you use tool like TortoiseGit Because, It allows you to do all your stuffs without being worried about commands because all the commands will be taken care for you

All you have to do is dealing with your context menu by right-clicking while you are inside your project folder

The image you will see during commit stage before pushing it to your remote repo

This is last step after it is successfully pushed remotely:

Happy Coding!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top