git rebase 不更改提交时间戳 [英] git rebase without changing commit timestamps
问题描述
在保留提交时间戳的同时执行 git 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)
如果理论上可行,那么在实践中是否可以使用 rebase,而不是更改时间戳?
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>
现在,如果我在 master
上重新设置 oldbranch
,则提交日期会从 1984 年 2 月更改为 2010 年 6 月.是否可以更改该行为以便提交时间戳没变?最后我会得到:
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>
|
:
这有意义吗?在 git 中是否允许有一个历史,其中一个旧的提交有一个更新的提交作为父级?
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?
推荐答案
Von C 的一个关键问题帮助我理解了发生了什么:当你的 rebase 时,committer 的时间戳改变了,但没有作者的时间戳,突然间一切都变得有意义了.所以我的问题其实不够准确.
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.
答案是 rebase 实际上并没有改变作者的时间戳(你不需要为此做任何事情),这非常适合我.
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屋!