RError.com

RError.com Logo RError.com Logo

RError.com Navigation

  • 主页

Mobile menu

Close
  • 主页
  • 系统&网络
    • 热门问题
    • 最新问题
    • 标签
  • Ubuntu
    • 热门问题
    • 最新问题
    • 标签
  • 帮助
主页 / 问题 / 1229350
Accepted
Artem
Artem
Asked:2022-01-10 18:58:59 +0000 UTC2022-01-10 18:58:59 +0000 UTC 2022-01-10 18:58:59 +0000 UTC

替换 GIT 中的提交日期

  • 772

我想将现有存储库添加到 GitHub。由于它显示来自 CommitDate 字段的提交日期,因此我想将所有提交的 CommitDate 设置为等于 AuthorDate。git rebase找到命令的选项--committer-date-is-author-date。对所有提交执行,从最古老的提交开始。但是初始提交的日期没有改变。事实上,为什么?

user@PC ~/myrepo
$ git rebase --committer-date-is-author-date e727c96
First, rewinding head to replay your work on top of it...
Применение: Return correct error code in error callback
Применение: Move files to root folder

user@PC ~/myrepo
$ git rebase --committer-date-is-author-date 9e61101
First, rewinding head to replay your work on top of it...
Применение: Move files to root folder

user@PC ~/myrepo
$ git rebase --committer-date-is-author-date a0c1b7a
First, rewinding head to replay your work on top of it...
Fast-forwarded master to a0c1b7a.

user@PC ~/myrepo
$ git log --pretty=fuller
commit a0c1b7a9d5c331a088555567d20631d94c107523 (HEAD -> master, origin/master)
Author:     XXXX <xxxx@xxxx>
AuthorDate: Sun Jan 10 13:25:15 2021 +0300
Commit:     XXXX <xxxx@xxxx>
CommitDate: Sun Jan 10 13:25:15 2021 +0300

    Move files to root folder

commit 9e611015ee95fbacf0ee267e0770c1eeda28b8aa
Author:     XXXX <xxxx@xxxx>
AuthorDate: Sun Jun 14 21:34:58 2020 +0300
Commit:     XXXX <xxxx@xxxx>
CommitDate: Sun Jun 14 21:34:58 2020 +0300

    Return correct error code in error callback

commit e727c9609b0787d8b93f0570cd36389a36cc79f0
Author:     XXXX <xxxx@xxxx>
AuthorDate: Tue Mar 31 19:32:50 2020 +0300
Commit:     XXXX <xxxx@xxxx>
CommitDate: Sun Jan 10 13:16:23 2021 +0300

    Initial commit
git
  • 1 1 个回答
  • 10 Views

1 个回答

  • Voted
  1. Best Answer
    aleksandr barakin
    2022-01-10T19:43:28Z2022-01-10T19:43:28Z

    但是初始提交的日期没有改变。事实上,为什么?

    在做的时候

    $ git rebase --committer-date-is-author-date хэш
    

    更改作为具有指定哈希的提交的子提交的提交。即,要更改某个提交,您必须指定其祖先的哈希值。

    历史上的第一次提交没有祖先。因此,不可能用这样的命令更改第一次提交。


    对于所有提交,我想将 CommitDate 设置为 AuthorDate

    例如,这可以通过filter-branch带有选项的命令来实现--commit-filter。这就是特殊指针指向的所有提交的“提交者日期”日期将如何更改HEAD:

    $ git filter-branch --commit-filter 'GIT_COMMITTER_DATE="${GIT_AUTHOR_DATE}" git commit-tree "$@"'
    

    插图。第一的:

    $ git log --pretty=fuller
    commit aef63a9e414abf06c92bae83c14269b1fa2b59a2 (HEAD -> master)
    Author:     user <user@host>
    AuthorDate: Wed Jan 1 01:01:02 2020 +0300
    Commit:     user <user@host>
    CommitDate: Sun Feb 2 02:02:02 2020 +0300
    
        2
    
    commit e6efa87163649f328700d60f54f3a3cc587266aa
    Author:     user <user@host>
    AuthorDate: Wed Jan 1 01:01:01 2020 +0300
    Commit:     user <user@host>
    CommitDate: Sun Feb 2 02:02:02 2020 +0300
    
        1
    

    更改日期:

    $ git filter-branch --commit-filter 'GIT_COMMITTER_DATE="${GIT_AUTHOR_DATE}" git commit-tree "$@"'
    Rewrite aef63a9e414abf06c92bae83c14269b1fa2b59a2 (2/2) (0 seconds passed, remaining 0 predicted)    
    Ref 'refs/heads/master' was rewritten
    $ git log --pretty=fuller
    commit 4ad12c93f15065fcd6174807bd6b9fa7ccee02f6 (HEAD -> master)
    Author:     user <user@host>
    AuthorDate: Wed Jan 1 01:01:02 2020 +0300
    Commit:     user <user@host>
    CommitDate: Wed Jan 1 01:01:02 2020 +0300
    
        2
    
    commit 5ef4883905240a32a4906af741dcca7e2daf8c05
    Author:     user <user@host>
    AuthorDate: Wed Jan 1 01:01:01 2020 +0300
    Commit:     user <user@host>
    CommitDate: Wed Jan 1 01:01:01 2020 +0300
    
        1
    
    • 1

相关问题

  • 在 github Web 界面中添加了一个文件。如何将其上传到本地存储库?

  • 在服务器上安装 Git

  • 如何在 GitHub 上的搜索中与我正在寻找的字符串完全匹配?

  • 有限访问 gitlab 进行 QA

  • 如何查看 GitHub 上所有创建的分支

  • 在 Git 中是否可以更改(而不是删除)整个历史记录中的特定文件

Sidebar

Stats

  • 问题 10021
  • Answers 30001
  • 最佳答案 8000
  • 用户 6900
  • 常问
  • 回答
  • Marko Smith

    表格填充不起作用

    • 2 个回答
  • Marko Smith

    提示 50/50,有两个,其中一个是正确的

    • 1 个回答
  • Marko Smith

    在 PyQt5 中停止进程

    • 1 个回答
  • Marko Smith

    我的脚本不工作

    • 1 个回答
  • Marko Smith

    在文本文件中写入和读取列表

    • 2 个回答
  • Marko Smith

    如何像屏幕截图中那样并排排列这些块?

    • 1 个回答
  • Marko Smith

    确定文本文件中每一行的字符数

    • 2 个回答
  • Marko Smith

    将接口对象传递给 JAVA 构造函数

    • 1 个回答
  • Marko Smith

    正确更新数据库中的数据

    • 1 个回答
  • Marko Smith

    Python解析不是css

    • 1 个回答
  • Martin Hope
    Alexandr_TT 2020年新年大赛! 2020-12-20 18:20:21 +0000 UTC
  • Martin Hope
    Alexandr_TT 圣诞树动画 2020-12-23 00:38:08 +0000 UTC
  • Martin Hope
    Air 究竟是什么标识了网站访问者? 2020-11-03 15:49:20 +0000 UTC
  • Martin Hope
    Qwertiy 号码显示 9223372036854775807 2020-07-11 18:16:49 +0000 UTC
  • Martin Hope
    user216109 如何为黑客设下陷阱,或充分击退攻击? 2020-05-10 02:22:52 +0000 UTC
  • Martin Hope
    Qwertiy 并变成3个无穷大 2020-11-06 07:15:57 +0000 UTC
  • Martin Hope
    koks_rs 什么是样板代码? 2020-10-27 15:43:19 +0000 UTC
  • Martin Hope
    Sirop4ik 向 git 提交发布的正确方法是什么? 2020-10-05 00:02:00 +0000 UTC
  • Martin Hope
    faoxis 为什么在这么多示例中函数都称为 foo? 2020-08-15 04:42:49 +0000 UTC
  • Martin Hope
    Pavel Mayorov 如何从事件或回调函数中返回值?或者至少等他们完成。 2020-08-11 16:49:28 +0000 UTC

热门标签

javascript python java php c# c++ html android jquery mysql

Explore

  • 主页
  • 问题
    • 热门问题
    • 最新问题
  • 标签
  • 帮助

Footer

RError.com

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

帮助

© 2023 RError.com All Rights Reserve   沪ICP备12040472号-5