Skip to content

Instantly share code, notes, and snippets.

@ythecombinator
Last active March 16, 2022 18:35
Show Gist options
  • Star 36 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save ythecombinator/7e70d7baea74305c93e6 to your computer and use it in GitHub Desktop.
Save ythecombinator/7e70d7baea74305c93e6 to your computer and use it in GitHub Desktop.
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
Copy link

parvezk commented Feb 2, 2018

Thank you! This was helpful

@ip1981
Copy link

ip1981 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
Copy link

Dirty trick, thanks.

@fuaad
Copy link

fuaad commented Jun 20, 2021

git commit --amend --date "Tue, 12 Jun 2018 12:40:00 -0300"
"--date" is not a valid option

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment