slier
slier

Reputation: 6750

Git how to edit commit message and preserve old commit date

I just import my porject from svn to git

So i plan to do some cleanup to my commit history

Let say i have this kind of commit history (all already been push)

Commit   Message                                 Date  
..
ffa7e08  change error message on isfileuploade.. 2012-06-04

85a467f  change error message on extension..    2012-05-24

49f3a89  add exit(), on execute() method ..     2012-05-09

af68b2b  add method getFileName                2012-05-04
..

How can i change the commit message for 49f3a89 without changing it date?

If i do git rebase -i af68b2b, i successfully change the commit message and apparently it old commit date too..

Is there a way to remedy this?

Upvotes: 1

Views: 3039

Answers (2)

slier
slier

Reputation: 6750

Taking from this stackoverflow answer:

git filter-branch --env-filter 'GIT_COMMITTER_DATE=$GIT_AUTHOR_DATE; export GIT_COMMITTER_DATE'

…did solve my problem.

Upvotes: 6

xproph
xproph

Reputation: 1241

How about that:

  1. gitk --all // for better viewing
  2. right click on commit 49f3a89 and reset dev branch to here
  3. git gui and commit -> ammend last commit
  4. now you are able to ammend commit 49f3a89 with whatever data you want
  5. commit and you can cherry pick changes from later commit af68b2b

Not sure if that's help?

Upvotes: 0

Related Questions