Olivier Verdier Olivier Verdier - 3 years ago 164
Git Question

git rebase without changing commit timestamps

Would it make sense to perform

git rebase
while preserving the commit timestamps?

I believe a consequence would be that the new branch will not necessarily have commit dates chronologically. Is that theoretically possible at all? (e.g. using plumbing commands; just curious here)

If it is theoretically possible, then is it possible in practice with rebase, not to change the timestamps?

For example, assume I have the following tree:

master <jun 2010>
: oldbranch <feb 1984>
: /
oldcommit <jan 1984>

Now, if I rebase
, the date of the commit changes from feb 1984 to jun 2010. Is it possible to change that behaviour so that the commit timestamp is not changed? In the end I would thus obtain:

oldbranch <feb 1984>
master <jun 2010>

Would that make sense at all? Is it even allowed in git to have a history where an old commit has a more recent commit as a parent?

Answer Source

A crucial question of Von C helped me understand what is going on: when your rebase, the committer's timestamp changes, but not the author's timestamp, which suddenly all makes sense. So my question was actually not precise enough.

The answer is that rebase actually doesn't change the author's timestamps (you don't need to do anything for that), which suits me perfectly.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download