Add a new tool?
bokub opened this issue · 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?
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" = "john.doe@gmail.com" ||
test "$GIT_COMMITTER_EMAIL" = "john.doe@gmail.com"; then
export GIT_AUTHOR_EMAIL="jack.doe@gmail.com"
export GIT_COMMITTER_EMAIL="jack.doe@gmail.com"
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.
oh, cool :)