Skip to content

Instantly share code, notes, and snippets.

@JARVIS-AI
Last active June 29, 2019 19:57
Show Gist options
  • Save JARVIS-AI/05a033ef51e5ae0276666bf3774dde41 to your computer and use it in GitHub Desktop.
Save JARVIS-AI/05a033ef51e5ae0276666bf3774dde41 to your computer and use it in GitHub Desktop.

Git repo date (Rewrite history)

These codes tested in macOS and Linux both In windows you need regkey | cmd /c /v | or set command to replace export in UNIX terminal

Another things that important are the ENVs : GIT_COMMITTER_DATE and GIT_AUTHOR_DATE that need to be set before you commit your changes

If you want only change date with not any change at all add --no-edit to your command

These codes for Linux and macOS

export GIT_COMMITTER_DATE="Wed Jan 1 14:55:00 2015 +0100"
git commit --amend --date "Wed Jan 1 14:55:00 2015 +0100" -m 'fix committer_date and author_date'
unset GIT_COMMITTER_DATE

export GIT_COMMITTER_DATE="2015-01-01 14:55:00 +0100"
git commit --amend --date "2015-01-01 14:55:00 +0100" -m 'fix committer_date and author_date'
unset GIT_COMMITTER_DATE

With no changes at all

export GIT_COMMITTER_DATE="Wed Jan 1 14:55:00 2015 +0100"
git commit --amend --no-edit --date "Wed Jan 1 14:55:00 2015 +0100" -m 'fix committer_date and author_date'
unset GIT_COMMITTER_DATE

export GIT_AUTHOR_DATE="2015-01-01 14:55:00 +0100"
git commit --amend --no-edit --date "2015-01-01 14:55:00 +0100" -m 'fix committer_date and author_date'
unset GIT_AUTHOR_DATE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment