I want to change the authorization name of the last few commits.

Asked 1 years ago, Updated 1 years ago, 74 views

I learned that you can change the authorization name of all past commit names with the following command:

$git filter-branch --commit-filter'
GIT_AUTHOR_NAME="idesaku"
GIT_AUTHOR_EMAIL=" (email address)"
GIT_COMMITTER_NAME="idesaku"
GIT_COMMITTER_EMAIL=" (email address)"
git commit-tree "$@"
' HEAD

In rare cases, I commit to my personal email account, and I would like to use it in such cases.

You can change the author name for the most recent commit name, or for all commit names, but
For all commit names, it takes time to rewrite and it takes time for the other party to git pull as well.

Therefore, we are looking for a way to rewrite the last 5 commits.

git commit-tree "$@"

I'm looking into it because I thought it might be the liver.
I didn't know how to get the last five.

Even if it's not the last few cases, it's okay to only target the differential commitment to the develop branch because we're working on it by cutting off the branch.

Thank you for your cooperation.

git github

2022-09-30 21:26

1 Answers

The filter-branch can be rev-list, so if it's the last five,

$git filter-branch --commit-filter'
GIT_AUTHOR_NAME="idesaku"
GIT_AUTHOR_EMAIL=" (email address)"
GIT_COMMITTER_NAME="idesaku"
GIT_COMMITTER_EMAIL=" (email address)" 
git commit-tree"$@"'HEAD~5..HEAD

How about

https://git-scm.com/docs/git-filter-branch


2022-09-30 21:26

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.