前言

创作开始时间:2021年9月11日15:44:56

有时候论文提交时对应的repo需要放在github上,这个时候不小心漏了一个commit,补上的话时间戳会很尴尬,所以需要对commit date进行修改,这里给出解决方案。

问题描述

我有一个repo,只有一个commit:

Author: xxx
Date:   Mon Sep 2 16:21:24 2021 +0800

    Make all artifacts of our study available.

但是过了几天后,我发现有一个材料忘记提交了。。。尬住

所以需要:
1)先补上这个提交材料
2)修改commit时间,使其仍然保持原来的Mon Sep 2 16:21:24 2021 +0800时间。

解决方案

1)补上提交材料:

git add .
git commit --amend --no-edit

2)修改commit提交时间:

GIT_COMMITTER_DATE="Mon Sep 2 16:21:24 2021 +0800" git commit --amend --date "Mon Sep 2 16:21:24 2021 +0800"
git commit --amend --date "Mon Sep 2 16:21:24 2021 +0800"

3)同步到github仓库

git push origin master

错误尝试

只运行:

git commit --amend --date "<date>"

而没有运行:

GIT_COMMITTER_DATE="<date>" git commit --amend --date "<date>"

是根本改不了github上的显示时间的。

小结

以上。

创作结束时间:2021年9月13日09:48:15

参考文献

Logo

AtomGit 是由开放原子开源基金会联合 CSDN 等生态伙伴共同推出的新一代开源与人工智能协作平台。平台坚持“开放、中立、公益”的理念,把代码托管、模型共享、数据集托管、智能体开发体验和算力服务整合在一起,为开发者提供从开发、训练到部署的一站式体验。

更多推荐