tips icon indicating copy to clipboard operation
tips copied to clipboard

Add a new tool?

Open bokub opened this issue 8 years ago • 3 comments

Hi, From what I can see, there is no tip talking about rewriting the commit history (authors, messages, dates), which is done with the git-filter-branch command.

This command is really not easy to use, and I don't see how it would be possible to add a one-line tip about that.

However, I have created a tool to help people doing that. You can check it out at git.io/editor, and the github repo is here

Do you think it would be possible to add it in the tools section? Or maybe add it in a tip?

bokub avatar Sep 02 '17 13:09 bokub

hey @bokub, i just added such command! see PR #153

eliranmal avatar Oct 30 '17 10:10 eliranmal

I was actually talking about the other usages of git-filter-branch: editing commit messages, author names, emails and date, without changing the files or the code.

For example, the following will change a commit date and its message:

git filter-branch --env-filter \
'if test "$GIT_COMMIT" = "022c0838480ddec334e85dd8a8ca7d376eb26d95"; then
    export GIT_AUTHOR_DATE="1273770000"
    export GIT_COMMITTER_DATE="1273770000"
fi' --msg-filter \
'if test "$GIT_COMMIT" = "022c0838480ddec334e85dd8a8ca7d376eb26d95"; then
    echo "New commit message"
else cat
fi' && rm -fr "$(git rev-parse --git-dir)/refs/original/"

and the following will replace any John Doe by Jack Doe, as well as his e-mail

git filter-branch --env-filter \
'if test "$GIT_AUTHOR_NAME" = "John Doe" ||
    test "$GIT_COMMITTER_NAME" = "John Doe"; then
    export GIT_AUTHOR_NAME="Jack Doe"
    export GIT_COMMITTER_NAME="Jack Doe"
fi; if test "$GIT_AUTHOR_EMAIL" = "[email protected]" ||
    test "$GIT_COMMITTER_EMAIL" = "[email protected]"; then
    export GIT_AUTHOR_EMAIL="[email protected]"
    export GIT_COMMITTER_EMAIL="[email protected]"
fi; fi' && rm -fr "$(git rev-parse --git-dir)/refs/original/"

But as these commands are quite complicated, I made a tool to generate them using your git log.

bokub avatar Oct 30 '17 21:10 bokub

oh, cool :)

eliranmal avatar Oct 30 '17 22:10 eliranmal