git – change date of commit

If you want for whatever reason change date of the existing commit you can use the following snippet (PowerShell)

If you want to modify date of the last commit

$commitDateString = "2010-01-01T14:30:00"
$env:GIT_COMMITTER_DATE = $commitDateString
git commit --amend --date $commitDateString
$env:GIT_COMMITTER_DATE = ""

For full list of supported date formats type

git commit --help

and look at DATE FORMATS section

If you need to change date of the non-last commit you would need to use interactive rebase first, select edit for those commits that should be changed and then apply approach shown above

Advertisements

About mnaoumov

Senior .NET Developer in Readify
This entry was posted in Uncategorized and tagged , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s