How to automatically edit commits after "git-rebase -i"?

Very often I need to change the date of n previous commits. Usually I do git rebase -i @~20 and then in the editor manually change pick to edit, after that run in the loop commit --amend with desired date. It all works nicely, but I would like to automate the process so that the editor would not be called at all.

The question is: how do I switch to "edit mode" automatically after git rebase?

Upvotes: 2

Views: 214

Answers (1)

Vasfed
Vasfed

Reputation: 18474

You can write a script that will behave like an editor and does what you want(it will be called with a temporary file and should modify it), then run the rebase with it - EDITOR=/path/to/your/script git rebase -i @~20

Also you might want to look onto git filter-branch approach suggested in How can one change the timestamp of an old commit in Git?

Upvotes: 2

Related Questions