Reputation:
I tend to amend
and rebase
a lot since I do small commits and usually group (read: squash
) them in the end to have a coherent (like in nice) history.
Being said that, I would like to have the same info from author and committer for every commit in a given branch, so I was wondering if there was a way to do this "natively" with Git.
Basically, what I'm looking for is:
master
), e.g.: git rev-list master..HEAD
git log --format=%aD --no-walk
) and apply the change(s)In that way, the committer's info is the same as the author's info — because nothing else changes for my case, except the dates.
I know can do this interactively, but I was wondering if there was a Git-fu command that would let me do such thing.
Upvotes: 0
Views: 49
Reputation: 60255
Filter-branch supplies the standard utility functions (from libexec/git-core/git-sh-setup
) to the filters you run, so
git filter-branch \
--setup 'eval `get_author_ident_from_commit thatcommit`
targetname=$GIT_AUTHOR_NAME
targetemail=$GIT_AUTHOR_EMAIL
' \
--env-filter '
GIT_AUTHOR_NAME=$targetname
GIT_AUTHOR_EMAIL=$targetemail
GIT_COMMITTER_NAME=$targetname
GIT_COMMITTER_EMAIL=$targetemail
' \
--tag-name-filter cat \
-- master..
To do this with belt-and-suspenders, do it in a scratch clone:
git clone -ns --mirror . `mktemp -d`; cd $_
# the above filter-branch
# if everything looks good,
git push origin HEAD
cd -
Upvotes: 1