views:

55

answers:

1

Apparently I mistyped my email a long time ago, whenever I was setting up git, and so my email has been incorrect in many repositories (I typed a 0 instead of an o). I sign all of my commits, so in almost every commit in every repo for years it's said signed off by: <[email protected]> instead of signed off by: <[email protected]>. Now I can't just switch my email, so I would like to switch these commit messages.

I've already done the git config --global user.email "[email protected]", so this shouldn't be a problem in the future.

Firstly, is it possible to change the messages on this large of a scale without royally messing things up? I've already pushed these changes to multiple servers and others have pulled those changes.

Second, is there a way I could do this quickly in a script? ie:

foreach(commit in log)
{
    change "<[email protected]>" to "<[email protected]>"
}

All help is appreciated, and thanks!

+6  A: 

If the changesets have already been made public and others have pulled them, then you should not touch them. Modifying them will change their SHAs, which will screw things up for others on a royal scale (see the "Recovering from Upstream Rebase" section on the git rebase page).

Now that I've mentioned that, suppose hypothetically they hadn't been made public. If that were the case, the tool you'd want to use to modify them all would be git filter-branch.

Amber
Well what should I do then? I have a bunch of commits pointing to an email that isn't mine (and is already registered, mind you).
adam_0
Um, there's not really a good solution here. In general, I'd say just let people know about the mistake, and leave it as-is.
Amber
Say there's only one server for the data, and it would be trivial to nuke the repository on the server side and start afresh (and ask everybody to do the same with their copies) -- would that accomplish the same task?
adam_0
Well, if it's trivial to nuke and start afresh, you could use `git filter-branch`, force-push to the server, and then require everyone to re-clone; they'd just have to make sure not to have any local work left over (since it wouldn't transfer to the new clone).
Amber
As always: what you are doing here is rewriting history. And just as in the real world, rewriting history requires a conspiracy to work. So, if you have full control over everybody who ever pulled from you, and everybody who ever pulled from someone who pulled from you, and everbody who ever pulled from someone who pulled from someone who pulled from you, and so on, *then* (and *only* then) can you change history.
Jörg W Mittag