Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Changin' a commit timestamp.

Changing a commit date info

Reason

My country is under a daylight saving time period and not all my commits are made during the morning/afternoon. Because I commited after 11:00 PM - which, given the local DST, was after 00:00 AM - my 100+ days commit streak got broken - which made me very unhappy.

The process

To understand more about author X committer see this.

Changing GIT_AUTHOR_DATE:

The author is the person who originally wrote the code.

git commit --amend --date "date"

This can be enough to solve broken-github-streak issues.

Changing GIT_COMMITTER_DATE:

The committer is assumed to be the person who committed the code on behalf of the original author.

GIT_COMMITTER_DATE="date" git commit --amend --date "date"

Tips

  • GIT_COMMITTER_DATE is an environment variable to change the committer timestamp.
  • The --amend flag is used for changing things in your last commit. For more info about git commit --amend see this.
  • The --date flag specifies the author date.
  • The date - which is assigned to GIT_COMMITTER_DATE and passed to --date should be like: <day of the week>, <day of the month> <month> <year> <hour> <time zone>, eg: git commit --amend --date "Sun, 18 Oct 2015 12:40:00 -0300"
@parvezk

This comment has been minimized.

Copy link

commented Feb 2, 2018

Thank you! This was helpful

@ip1981

This comment has been minimized.

Copy link

commented Feb 23, 2018

The date - which is assigned to GIT_COMMITTER_DATE and passed to --date should be like: , , eg: git commit --amend --date "Sun, 18 Oct 2015 12:40:00 -0300"

date -R with the GNU coreutils

@ailjushkin

This comment has been minimized.

Copy link

commented Apr 26, 2018

Dirty trick, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.