前言

创作开始时间: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

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐