From 819b14a73f2e87cbfc58613a5bb0c2bcb7a45763 Mon Sep 17 00:00:00 2001 From: lumynou5 Date: Tue, 14 May 2024 13:58:41 +0800 Subject: [PATCH] Add method to change authors for multiple commits --- README.md | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 0401105..044f72a 100644 --- a/README.md +++ b/README.md @@ -329,7 +329,14 @@ An alternative is to correctly configure your author settings in `git config --g $ git commit --amend --reset-author --no-edit ``` -If you need to change all of history, see the man page for `git filter-branch`. +If you need to change for multiple commits, you can use + +```sh +$ git -c rebase.instructionFormat='%s%nexec GIT_COMMITTER_DATE="%cD" GIT_AUTHOR_DATE="%aD" git commit --amend --no-edit --reset-author' rebase -r +``` + +`` is a commit before all your bad commits. If you need to change all of history in the current branch including the root of the branch, put `--root` there instead. +Note this will change the history and a force push is required. ### I want to remove a file from the previous commit