JGit 将过去(旧)日期提交到本地存储库

问题描述 投票:0回答:0

我想 在过去的特定日期使用 Java 中的 JGit 提交。例如,我想在 2023-03-01、2023-03-02、2023-03-03、2023-03-04 提交到本地存储库。根据许多网站(包括 StackOverflow 帖子),我可以通过以下方式实现:

String oldDate = "2023-03-01";

PersonIdent author = new PersonIdent("X", String.valueOf(oldDate));
PersonIdent committer = new PersonIdent("X", String.valueOf(oldDate));

git.commit().setAuthor(author).setCommitter(committer).setMessage("Modified temp.txt").call();

但是,这并不能满足我的要求,因为日期保持不变,即来自系统的实际日期。我在 Git Bash 中使用

git log
检查了结果:(请检查这张图片

我怎样才能对过去的日期进行提交? 感谢所有帮助!

git date datetime git-commit jgit
© www.soinside.com 2019 - 2024. All rights reserved.