首页 > 解决方案 > 第一次提交的更改(不更改日期)

问题描述

我想向我的存储库中的第一个提交添加更改。我做了以下命令:

git tag root `git rev-list HEAD | tail -1`
git checkout -b new-root root
// changes in code
git add .
GIT_COMMITTER_DATE="Mon Oct 1 22:36:58 2018 +0200"
git commit --amend --no-edit --date="Mon Oct 1 22:36:58 2018 +0200"
git checkout @{-1}
git rebase --onto new-root root --committer-date-is-author-date
git branch -d new-root
git tag -d root
git push origin master --force

一切正常,除了在文件列表(GitLab)中,那些未被任何提交修改的文件的日期更新为新的:

来自 GitLab 的屏幕截图

来自 GitLab 的屏幕截图

谁能告诉我如何改进它?提前谢谢你!

标签: gitgitlab

解决方案


为了确保您的最后一个参数不会被忽略,您可以重复您的序列:

 git rebase --committer-date-is-author-date --onto new-root root 
 # instead of
 git rebase --onto new-root root --committer-date-is-author-date

您需要先使用或恢复root分支。git refloggit reset --hard ORIG_HEAD

然后在 rebase 之前和之后首先检查根分支的作者/提交者日期:

git log --graph --pretty=format:"%aD --- %cD" root

推荐阅读