4

I wanted to add changes to the first commit in my repository. I made the following commands:

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

Everything works, except that in the list of files (GitLab), those that have not been modified by any commit have Date update as new:

screenshot from GitLab

screenshot from GitLab

Can anyone tell me how to improve it? Thanks you in advance!

2 Answers2

0

Just to be sure your last parameter is not ignored, can you repeat your sequence with:

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

You will need to restore the root branch first, using git reflog or git reset --hard ORIG_HEAD.

Then check first the author/committer dates of your root branch before and after rebase with:

git log --graph --pretty=format:"%aD --- %cD" root
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
0

I assume that your new first commit (new-root) was wrong. These commands set only the author date but not the committer date because the value of GIT_COMMITTER_DATE is not propagated to into 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"

The simplest solution is to add a trailing \ like this just before the newline:

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"

Now git commit sees the variable.

A.H.
  • 63,967
  • 15
  • 92
  • 126