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: <xxx0@foo.bar> instead of signed off by: <xxxo@foo.bar>. 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 "xxxo@foo.bar", 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 "<xxx0@foo.bar>" to "<xxxo@foo.bar>"
}

All help is appreciated, and thanks!

adam_0
  • 6,920
  • 6
  • 40
  • 52
  • Is it really that big of the problem? How many people have your code but wouldn't know how to contact you? If it is an open source project, you probably would prefer communication through the project web site. If it is a commercial project, and complete strangers have access to your code and have no way to contact you, then you've probably lost your job. – mikerobi Oct 31 '10 at 00:23
  • I'd say it's a pretty big problem. A lot of the projects are small open-source projects that live only on github. Some of them are only ones that I've worked on, so a method that wouldn't work for bigger projects might be OK there, but some of them have multiple contributors and have been pulled from for years. Would I spend the time to write all this out if I didn't feel it was that big of a problem? – adam_0 Oct 31 '10 at 00:28

1 Answers1

6

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
  • 507,862
  • 82
  • 626
  • 550
  • 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 Oct 31 '10 at 00:23
  • 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 Oct 31 '10 at 00:24
  • 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 Oct 31 '10 at 00:43
  • 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 Oct 31 '10 at 00:49
  • 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 Oct 31 '10 at 10:16