gpt4 book ai didi

git - 更改 GIT 中的所有提交日期

转载 作者:太空狗 更新时间:2023-10-29 14:08:46 27 4
gpt4 key购买 nike

无论如何,我可以通过从所有日期中减去(比方说一周)来更改 GIT 中的所有提交日期。

喜欢,而不是展示“2012 年 9 月 10 日星期四,用户 promise ...”我想说“日期为 2012 年 9 月 3 日,星期一,用户 promise ...”

这仅适用于一个 GIT 存储库。谢谢!

最佳答案

是的,你可以用 git filter-branch 做到这一点.但是请注意,这也会影响所有哈希,所有提交都将被重新创建并重写 repo 历史。因此,这可能很危险。

您需要将 git filter-branch 与设置 GIT_AUTHOR_DATE 和 GIT_COMMITTER_DATE 变量的环境过滤器一起使用。在 github 中有 example script to change author info for all commits - 它是类似的东西,你只需要使用我提到的变量,并实现一个逻辑,根据给定的日期决定一周前的日期。

最后警告:如果有人已经使用过那个 repo,事情可能会变得一团糟。来自 github 页面:

This action is destructive to your repo's history. It's best to do this on a clone, just in case. Also beware that this should not be performed on a repo that has been shared with others. Use at your own risk.

关于git - 更改 GIT 中的所有提交日期,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13035324/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com