My git commit-date and author-date are different. I want to set the commit-date same as my author-date once and forever because changing past commits only won't be a permanent solution. Can someone suggest a command for the same?
My git commit-date and author-date are different. I want to set the commit-date same as my author-date once and forever because changing past commits only won't be a permanent solution. Can someone suggest a command for the same?
The first thing I think upon reading this question is: why do you care? This state of affairs—different commit and author dates—is normal under circumstances that are not at all unusual.
Note that a new commit you make right now will have the same two values for committer and author dates. The two drift apart when:
git am or similar to email commits around.In these cases, Git will try to keep the original author and author-date to the extent that this seems reasonable, while making you the committer and "now" the committer date. This is because no commit can ever be changed. What make this commit this commit is the fact that you made it just now: you took some existing commit, made some time ago, and used it as the basis for making a new commit, that you made just now. You didn't make this new commit yesterday, you made it now.
The new commit must have something different. If it's 100% identical to the old commit in every way—a bit-for-bit exact copy—then it literally is the old commit, and nothing has changed. You can preserve the committer date if something else has also changed, but is more logical to make the new commit with "now" as the date, to guarantee that enough is different to make it a different commit.
When using the am-based back end with git rebase, the --committer-date-is-author-date flag will set the committer date from the author date. So if your dates are changing because of rebasing, you can use that flag. (But that runs right into the "why bother" question.)
Other than what I just mentioned, there is nothing built in to Git here. You could of course modify Git: there's nothing secret about how it makes commits, or its source code.