没有改变提交时间戳的git rebase [英] git rebase without changing commit timestamps

查看:130
本文介绍了没有改变提交时间戳的git rebase的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在保留提交时间戳的情况下执行 git rebase 是否合理?



因为新分支不一定会按时间顺序提交日期。从理论上讲,可能吗? (例如,使用管道命令;只是好奇)



如果在理论上可行,那么在实践中是否可以使用rebase,而不是更改时间戳?



例如,假设我有以下树:

  master< jun 2010> ; 
|


:oldbranch< feb 1984>
:/
oldcommit< jan 1984>

现在,如果我将 oldbranch code> master ,提交的日期从1984年2月更改为2010年6月。是否可以更改该行为以便提交时间戳不会更改?最后,我会得到:

  oldbranch< feb 1984> 
/
master< jun 2010>
|

这是否合理?它甚至允许在git中有一个历史记录,其中一个旧的提交具有更近期的提交作为父项吗?

Von C的问题帮助我理解了发生了什么:当你的rebase,提交者的时间戳发生变化,而不是作者的时间戳时,这一切都变得有意义。所以我的问题其实不够准确。

答案是rebase实际上不会改变作者的时间戳(你不需要做任何事情),这完全适合我。


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 oldbranch on master, 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?

解决方案

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.

这篇关于没有改变提交时间戳的git rebase的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆