tags:

views:

92

answers:

3

I have a couple of commits where my email address is wrong in the history.

Should I, How can I rewrite this history to reflect the correct email address?

EDIT:

If I choose to rewrite history, what is it that another user will have to do to fix their checkout?

Thanks.

+2  A: 

If you are the only user of this repo or you don't care about possibly breaking the repo for other users, then yes. If you've pushed these commits and they exist where somewhere else can access them, then no, unless you don't care about breaking other people's repos. The problem is by changing these commits you will be generating new SHAs which will cause them to be treated as different commits. When someone else tries to pull in these changed commits, the history is different and kaboom.

This page http://inputvalidation.blogspot.com/2008/08/how-to-change-git-commit-author.html describes how to do it. (I haven't tried this so YMMV)

docgnome
So, there is no safe way to rewrite the user.email. Without blowing up everyone else. I knew that rewriting history was a bad idea, I just thought that there might be a clean way to do it safely. Thanks.
mediaslave
@mediaslave: Try `refs/replace/` mechanism.
Jakub Narębski
+4  A: 

As docgnome mentioned, rewriting history is dangerous and will break other people's repositories.

But if you really want to do that and you are in a bash environment (no problem in Linux, on Windows, you can use git bash, that is provided with the installation of git), use git filter-branch:

git filter-branch --env-filter 'if [ $GIT_AUTHOR_EMAIL = bad@email ]; then GIT_AUTHOR_EMAIL=correct@email; fi; export GIT_AUTHOR_EMAIL'

To speed things up, you can specify a range of revisions you want to rewrite.

svick
+1  A: 
Jakub Narębski