threads / discuss / 42095

git rebase -i without altering the committer date

Subject: git rebase -i without altering the committer date

## tl;dr

6 messages between Apr 20, 2016 and Apr 21, 2016.

replies: 5people: 5as markdown or json

Shaun Jackman· Apr 20, 2016, 20:24 UTC · lore
I'd like to insert a commit between two commits without changing the committer date or author date of that commit or the subsequent commits. I'd planned on using `git rebase -i` to insert the commit. I believe it retains the author date, but changes the committer date to the current time. I've seen the options `--committer-date-is-author-date` and `--ignore-date`, but I don't believe either of those options does what I want. If no such option currently exists to leave the committer and author date unchanged, is there any chance that this functionality could please be implemented?

For a relevant SO question, see How to make a git rebase and keep the commit timestamp? http://stackoverflow.com/questions/30790645/how-to-make-a-git-rebase-and-keep-the-commit-timestamp

Thanks, Shaun

-- 
http://sjackman.ca
Junio C Hamano· Apr 20, 2016, 20:36 UTC · re: Shaun Jackman · lore

Re: git rebase -i without altering the committer date

Shaun Jackman <sjackman@gmail.com> writes:
Show 10 quoted lines
> I'd like to insert a commit between two commits without changing
> the committer date or author date of that commit or the subsequent
> commits. I'd planned on using `git rebase -i` to insert the
> commit. I believe it retains the author date, but changes the
> committer date to the current time. I've seen the options
> `--committer-date-is-author-date` and `--ignore-date`, but I don't
> believe either of those options does what I want. If no such
> option currently exists to leave the committer and author date
> unchanged, is there any chance that this functionality could
> please be implemented?

You can mark the commit as "edit", use "git commit --amend" when "rebase -i" stops and gives control back to you, and say "rebase --continue". That way, you can use your favourite trick to lie about committer date (or identity or other aspects) when running "git commit --amend" and its effect will be left in the resulting history, I would think.

Shaun Jackman· Apr 20, 2016, 21:15 UTC · re: Junio C Hamano · lore

Re: git rebase -i without altering the committer date

On April 20, 2016 at 13:37:01, Junio C Hamano (gitster@pobox.com(mailto:gitster@pobox.com)) wrote:
Show 19 quoted lines
> Shaun Jackman writes: 
> 
> > I'd like to insert a commit between two commits without changing 
> > the committer date or author date of that commit or the subsequent 
> > commits. I'd planned on using `git rebase -i` to insert the 
> > commit. I believe it retains the author date, but changes the 
> > committer date to the current time. I've seen the options 
> > `--committer-date-is-author-date` and `--ignore-date`, but I don't 
> > believe either of those options does what I want. If no such 
> > option currently exists to leave the committer and author date 
> > unchanged, is there any chance that this functionality could 
> > please be implemented? 
> 
> You can mark the commit as "edit", use "git commit --amend" when 
> "rebase -i" stops and gives control back to you, and say "rebase 
> --continue". That way, you can use your favourite trick to lie 
> about committer date (or identity or other aspects) when running 
> "git commit --amend" and its effect will be left in the resulting 
> history, I would think. 
Thanks for the suggestion, Junio. That would retain the committer date for the commit being inserted. I believe that the subsequent commits would have their committer date modified to the current time by the `git rebase --continue`.

Cheers, Shaun

Andreas Schwab· Apr 20, 2016, 21:47 UTC · re: Shaun Jackman · lore

Re: git rebase -i without altering the committer date

Shaun Jackman <sjackman@gmail.com> writes:
> I'd like to insert a commit between two commits without changing the committer date or author date of that commit or the subsequent commits. I'd planned on using `git rebase -i` to insert the commit. I believe it retains the author date, but changes the committer date to the current time. I've seen the options `--committer-date-is-author-date` and `--ignore-date`, but I don't believe either of those options does what I want. If no such option currently exists to leave the committer and author date unchanged, is there any chance that this functionality could please be implemented?

The easiest way to implement that is to add a graft to redirect the parent of the second commit to the inserted commit, then use git filter-branch to make the graft permanent.

Andreas.
-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."
Johannes Sixt· Apr 21, 2016, 05:23 UTC · re: Andreas Schwab · lore

Re: git rebase -i without altering the committer date

Am 20.04.2016 um 23:47 schrieb Andreas Schwab:
Show 9 quoted lines
> Shaun Jackman <sjackman@gmail.com> writes:
>
>> I'd like to insert a commit between two commits without changing
>> the committer date or author date of that commit or the subsequent
>> commits.
>
> The easiest way to implement that is to add a graft to redirect the
> parent of the second commit to the inserted commit, then use git
> filter-branch to make the graft permanent.

This only inserts a new project state, but does not propagate the changes brought in by the new commit to the subsequent commits. This propagation of changes could also be done with filter-branch, but it may be difficult depending on circumstances.

-- Hannes
Johannes Schindelin· Apr 21, 2016, 07:17 UTC · re: Johannes Sixt · lore

Re: git rebase -i without altering the committer date

Hi,
On Thu, 21 Apr 2016, Johannes Sixt wrote:
Show 15 quoted lines
> Am 20.04.2016 um 23:47 schrieb Andreas Schwab:
> > Shaun Jackman <sjackman@gmail.com> writes:
> >
> > > I'd like to insert a commit between two commits without changing
> > > the committer date or author date of that commit or the subsequent
> > > commits.
> >
> > The easiest way to implement that is to add a graft to redirect the
> > parent of the second commit to the inserted commit, then use git
> > filter-branch to make the graft permanent.
> 
> This only inserts a new project state, but does not propagate the changes
> brought in by the new commit to the subsequent commits. This propagation of
> changes could also be done with filter-branch, but it may be difficult
> depending on circumstances.

I agree that rebase -i is the wrong wrench for this job. Either use filter-branch or fast-export/edit/fast-import.

Or take a step back and ask yourself why you need to fool anybody about the commit date... ;-D

Ciao, Johannes

← back to recent threads