Git 第一次提交中的更改(不更改日期)
我想向存储库中的第一次提交添加更改。 我发出了以下命令:Git 第一次提交中的更改(不更改日期),git,gitlab,Git,Gitlab,我想向存储库中的第一次提交添加更改。 我发出了以下命令: 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 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)中,没有被任何提交修改的文件的日期更新为新:
有人能告诉我如何改进吗?提前谢谢你 为了确保不忽略最后一个参数,您可以重复以下步骤:
git rebase --committer-date-is-author-date --onto new-root root
# instead of
git rebase --onto new-root root --committer-date-is-author-date
您需要首先使用或还原根
分支
然后首先检查根分支在重设基础前后的作者/提交人日期:
git log --graph --pretty=format:"%aD --- %cD" root
我假设您的新第一次提交(
newroot
)是错误的。这些命令只设置作者日期,而不设置提交人日期,因为GIT\u committer\u date
的值没有传播到GIT commit
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_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 commit
看到了变量