From 6cf69bc190c4f821a42ab6eb057e6531fb5e2e06 Mon Sep 17 00:00:00 2001 From: Shadab Zafar Date: Mon, 3 Aug 2015 17:44:58 +0530 Subject: [PATCH] Git cheats: Change date of existing commit --- cheat/cheatsheets/git | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/cheat/cheatsheets/git b/cheat/cheatsheets/git index 9aa57ca..469ee5d 100644 --- a/cheat/cheatsheets/git +++ b/cheat/cheatsheets/git @@ -22,6 +22,14 @@ git commit --date="`date --date='2 day ago'`" git commit --date="Jun 13 18:30:25 IST 2015" # more recent versions of Git also support --date="2 days ago" directly +# To change the date of an existing commit +git filter-branch --env-filter \ + 'if [ $GIT_COMMIT = 119f9ecf58069b265ab22f1f97d2b648faf932e0 ] + then + export GIT_AUTHOR_DATE="Fri Jan 2 21:38:53 2009 -0800" + export GIT_COMMITTER_DATE="Sat May 19 01:01:01 2007 -0700" + fi' + # To removed staged and working directory changes git reset --hard