在重新设置 git 分支时更改时间戳

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1579643/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 07:13:34  来源:igfitidea点击:

Change timestamps while rebasing git branch

gitgit-rebase

提问by tarsius

I have reorganized the commits in a branch before it is going to be made public causing the timestamps of the commits to be in an mixed up order. I would rather have them be all be today with only seconds in between.

在将提交公开之前,我已经在分支中重新组织了提交,导致提交的时间戳处于混乱状态。我宁愿让他们都在今天,中间只有几秒钟。

Obviously these time stamps won't be correct either, but since this is the time when things go public I prefer that over a mixed up history, time-wise.

显然,这些时间戳也不正确,但由于这是公开的时间,我更喜欢在时间上混淆的历史。

So how do I tell git to create new timestamps while rebasing?

那么如何告诉 git 在变基时创建新的时间戳呢?

回答by Michael Krelin - hacker

git rebase --ignore-date

回答by lkraav

In my case rebasing changed timestamps to CommitDate value, so in gitweb a bunch of months old commits showed up as 4 days old. I found the last commit with the correct date and did:

在我的例子中,rebase 将时间戳更改为 CommitDate 值,因此在 gitweb 中,一堆几个月前的提交显示为 4 天前。我找到了具有正确日期的最后一次提交并做了:

$ git rebase --committer-date-is-author-date SHA

回答by Umar Asghar

There are the following ways

有以下几种方式

  1. Normal rebase

    git rebase --ignore-date
    
  2. Interactive rebase

    git rebase -i master
    git commit --amend --date=now
    git push origin <branch> -f
    
  1. 正常变基

    git rebase --ignore-date
    
  2. 交互式变基

    git rebase -i master
    git commit --amend --date=now
    git push origin <branch> -f