I try to set the committer date of the latest commit to its author date. Usually this works with git rebase --committer-date-is-author-date HEAD~1
. Unfortunately there is only one commit which means that I have to use --root
instead of HEAD~1
but git rebase --committer-date-is-author-date --root
does not set the committer date to the author date for some reason. What can I do?
相关问题
- Date with SimpleDateFormat in Java
- Why does recursive submodule update from github fa
- Extended message for commit via Visual Studio Code
- Emacs shell: save commit message
- Can I organize Git submodules in a flat hierarchy?
相关文章
- 请教Git如何克隆本地库?
- GitHub:Enterprise post-receive hook
- Git Clone Fails: Server Certificate Verification F
- SSIS solution on GIT?
- MYSQL: How can I find 'last monday's date&
- Is there a version control system abstraction for
- Calculate number of working days in a month [dupli
- ssh: Could not resolve hostname git: Name or servi
The bad news
Unfortunately
git rebase --root
uses the interactive rebase code (because the non-interactive code cannot "replay" the root commit), and--committer-date-is-author-date
is actually a flag passed togit am
, which implements the simple non-interactive cases.The good news
What
git rebase
does, at a fundamental level, is copy some commits (with, usually, some sort of change made during the copying process), then point a branch name at the final such copied commit. If there is just one commit you want to change-while-copying, you can usegit commit --amend
instead ofgit rebase
.1 If there is only one commit in the entire repository, there can only be one commit that you need to change-while-copying, so this case will apply.Instead of
--committer-date-is-author-date
, you will need to use theGIT_COMMITTER_DATE
variable to set the commit time stamp to some arbitrary value. You can also use--author
and/or--date
to override the author name and/or time-stamp. Hence:would set both time stamps to September 1st of 2017, at 12:34:56. (I used a shell variable
t
here to avoid typing in the same time stamp twice.)(Add
--no-edit
if you don't want to edit the commit message. Remember that the new commit will use whatever is currently in the index! If you have changed the index since extracting the HEAD commit, you may want to copy theHEAD
commit to a temporary index first, and use that.)1This assumes the change you want to make is, e.g., the commit message text or date or author or some such, rather than the commit's parent ID. The definition of a root commit is one with no parent ID, and
git commit --amend
will continue to have no parent ID, which is what you want in this case.Actually, it might set it correctly, starting from Git 23.19 (Q3 2018)
The "
author-script
" file "git rebase -i
" creates got broken when we started to move the command away from shell script, which is getting fixed now.See commit 5522bba, commit 67f16e3, commit 0f16c09, commit ca3e182 (31 Jul 2018) by Eric Sunshine (
sunshineco
).(Merged by Junio C Hamano --
gitster
-- in commit 1bc505b, 17 Aug 2018)