Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a new tool? #151

Open
bokub opened this issue Sep 2, 2017 · 3 comments
Open

Add a new tool? #151

bokub opened this issue Sep 2, 2017 · 3 comments

Comments

@bokub
Copy link

bokub commented Sep 2, 2017

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?

@eliranmal
Copy link
Contributor

eliranmal commented Oct 30, 2017

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

@bokub
Copy link
Author

bokub commented Oct 30, 2017

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.

@eliranmal
Copy link
Contributor

oh, cool :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants